Skip to content

Commit 93fc861

Browse files
authored
Merge pull request #256 from Anshika14528/prmerged
Issue in autocommenting on merged pr #255
2 parents 1248ca4 + 7adc491 commit 93fc861

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Auto Comment on PR Merge
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types: [closed]
66

77
permissions:
@@ -10,27 +10,28 @@ permissions:
1010

1111
jobs:
1212
comment:
13-
runs-on: ubuntu-latest
14-
permissions:
15-
pull-requests: write
1613
if: github.event.pull_request.merged == true
14+
runs-on: ubuntu-latest
1715

1816
steps:
19-
- name: Checkout Repository
20-
uses: actions/checkout@v2
21-
22-
- name: Add Comment to Issue
23-
env:
24-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25-
run: |
17+
- name: Add Comment to Merged PR
18+
run: |
2619
COMMENT=$(cat <<EOF
2720
{
2821
"body": "🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀"
2922
}
3023
EOF
3124
)
32-
curl -X POST \
33-
-H "Authorization: Bearer $GITHUB_TOKEN" \
25+
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
26+
-X POST \
27+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
3428
-H "Accept: application/vnd.github.v3+json" \
3529
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
36-
-d "$COMMENT"
30+
-d "$COMMENT")
31+
cat response.json
32+
if [ "$RESPONSE" -ne 201 ]; then
33+
echo "Failed to add comment"
34+
exit 1
35+
fi
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)