Skip to content

Commit f10b8cd

Browse files
authored
Merge pull request #102 from imguoguo/main
feat: add issue tracker
2 parents e7a3fad + aea36d3 commit f10b8cd

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Issue Tracker
2+
3+
on:
4+
issues:
5+
types: [opened, reopened]
6+
7+
jobs:
8+
track-issue:
9+
name: Track Issue Updates
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Send Issue Data to API
14+
env:
15+
API_URL: ${{ secrets.ISSUE_TRACKER_API_URL }}
16+
VERIFY_TOKEN: ${{ secrets.VERIFY_TOKEN }}
17+
run: |
18+
ISSUE_DATA=$(cat <<EOF
19+
{
20+
"action": "${{ github.event.action }}",
21+
"issue": {
22+
"id": ${{ github.event.issue.id }},
23+
"number": ${{ github.event.issue.number }},
24+
"title": $(echo '${{ github.event.issue.title }}' | jq -R .),
25+
"body": $(echo '${{ github.event.issue.body }}' | jq -Rs .),
26+
"state": "${{ github.event.issue.state }}",
27+
"created_at": "${{ github.event.issue.created_at }}",
28+
"updated_at": "${{ github.event.issue.updated_at }}",
29+
"closed_at": "${{ github.event.issue.closed_at }}",
30+
"url": "${{ github.event.issue.html_url }}",
31+
"user": {
32+
"login": "${{ github.event.issue.user.login }}",
33+
"id": ${{ github.event.issue.user.id }}
34+
},
35+
"labels": $(echo '${{ toJSON(github.event.issue.labels) }}' | jq -c .),
36+
"assignees": $(echo '${{ toJSON(github.event.issue.assignees) }}' | jq -c .)
37+
},
38+
"repository": {
39+
"name": "${{ github.repository }}",
40+
"full_name": "${{ github.event.repository.full_name }}",
41+
"url": "${{ github.event.repository.html_url }}"
42+
},
43+
"sender": {
44+
"login": "${{ github.event.sender.login }}",
45+
"id": ${{ github.event.sender.id }}
46+
}
47+
}
48+
EOF
49+
)
50+
51+
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$API_URL" \
52+
-H "Content-Type: application/json" \
53+
-H "Token: $VERIFY_TOKEN" \
54+
-d "$ISSUE_DATA")
55+
56+
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
57+
58+
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
59+
echo "Successfully sent issue data to API"
60+
else
61+
echo "Failed to send issue data to API"
62+
exit 1
63+
fi

0 commit comments

Comments
 (0)