chore: adding slack notifications GH action #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Thank contributor for contribution' | |
on: | |
pull_request: | |
types: | |
- closed | |
jobs: | |
Congratulate: | |
if: | |
github.event.pull_request.merged == true && | |
github.event.pull_request.user.login != 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Thank contributor for contribution | |
env: | |
ISSUES_BOT_TOKEN: ${{ secrets.ISSUES_BOT_TOKEN }} | |
run: | | |
username="${{ github.event.pull_request.user.login }}" | |
repo="${{ github.repository }}" | |
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer $ISSUES_BOT_TOKEN" "https://api.github.com/repos/$repo/collaborators/$username") | |
if [ "$response" = "204" ]; then | |
message="Hi @$username. :wave:\n\nYour PR has been approved and merged. :tada:\n\nThank you for your continued contributions to this project. :heart:\n\nKeep up the great work!" | |
elif [ "$response" = "404" ]; then | |
message="Hi @$username. :wave:\n\nCongrats on your first PR being approved and merged into framework.dev! :tada:\n\nThank you for taking the time to contribute to our project. :heart:\n\nWe look forward to your next contribution. :rocket:" | |
else | |
echo "Invalid or expired token: $ISSUES_BOT_TOKEN" | |
exit 1 | |
fi | |
curl -X POST \ | |
-H "Authorization: Bearer $ISSUES_BOT_TOKEN" \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"body": "'"$message"'" | |
}' \ | |
"https://api.github.com/repos/$repo/issues/${{ github.event.pull_request.number }}/comments" |