Skip to content

Commit

Permalink
Merge pull request #1055 from Anshika14528/mergedPrYml
Browse files Browse the repository at this point in the history
Automate comment of every PR merge. #1033
  • Loading branch information
nikhil25803 authored Jun 6, 2024
2 parents 00ef1d3 + abd6a6a commit c4ae698
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/pr_merged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Auto Comment on PR Merged

on:
pull_request_target:
types: [closed]

permissions:
issues: write
pull-requests: write

jobs:
comment:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Add Comment to Pull Request
run: |
COMMENT=$(cat <<EOF
{
"body": "Great work @${{ github.event.pull_request.user.login }} !! \nDo not forget to \n+ Share your contribution on socials and tag Clueless 🫂 \n+ Give this repository a star ✨ \n+ Follow Clueless Community on GitHub ✅"
}
EOF
)
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$COMMENT")
cat response.json
if [ "$RESPONSE" -ne 201 ]; then
echo "Failed to add comment"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit c4ae698

Please sign in to comment.