-
Notifications
You must be signed in to change notification settings - Fork 9
56 lines (51 loc) · 1.67 KB
/
Auto_message_on_pr_open.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Auto Comment on PR Open
on:
pull_request_target:
types: [opened]
permissions:
issues: write
pull-requests: write
jobs:
comment-on-open:
runs-on: ubuntu-latest
steps:
- name: Add Comment to Opened PR
run: |
COMMENT=$(cat <<EOF
{
"body": "👋 Thank you for opening this pull request! We're excited to review your contribution. Please give us a moment, and we'll get back to you shortly!"
}
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 on PR open"
exit 1
fi
- name: Add Reviewer to Pull Request
run: |
REVIEWERS=$(cat <<EOF
{
"reviewers": ["aayank13"]
}
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 }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \
-d "$REVIEWERS")
cat response.json
if [ "$RESPONSE" -ne 201 ]; then
echo "Failed to add reviewer"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}