Repository navigation
58 lines (53 loc) · 2.08 KB
/
Copy pathautocomment-pr-raise.yml
File metadata and controls
58 lines (53 loc) · 2.08 KB
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
57
58
name: Auto Comment on PR
on:
pull_request_target:
types: [opened]
permissions:
issues: write
pull-requests: write
jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: Add Comment to Pull Request
run: |
COMMENT=$(cat <<EOF
{
"body": "Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our [CONTRIBUTING.md](https://github.com/your-repo/your-project/blob/main/CONTRIBUTING.md). If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊"
}
EOF
)
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
-X POST \
-H "Authorization: token $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")
if [ "$RESPONSE" -ne 201 ]; then
cat response.json
echo "Failed to add comment (HTTP $RESPONSE)"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Assign PR Creator
run: |
ASSIGNEE="${{ github.event.pull_request.user.login }}"
export ASSIGNEE
PAYLOAD=$(python3 -c 'import json, os; print(json.dumps({"assignees": [os.environ["ASSIGNEE"]]}))') || {
echo "Failed to construct assignment payload"
exit 1
}
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
-X PATCH \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }} \
-d "$PAYLOAD")
if [ "$RESPONSE" -ne 200 ]; then
cat response.json
echo "Failed to assign PR creator (HTTP $RESPONSE)"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}