-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (77 loc) · 2.71 KB
/
Copy pathspin-issue-tracker.yml
File metadata and controls
96 lines (77 loc) · 2.71 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Track Spin Resolved Issues
on:
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
permissions:
contents: write
issues: read
jobs:
track-issues:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Fetch All Closed Issues (GraphQL)
run: |
TOKEN=${{ secrets.PAT_TOKEN }}
OWNER="3ee-Games"
REPO="bonus-round"
fetch_issues() {
LABEL=$1
END_CURSOR=$2
QUERY="{\"query\": \"query {
repository(owner: \\\"$OWNER\\\", name: \\\"$REPO\\\") {
issues(first: 100, labels: [\\\"$LABEL\\\"], states: CLOSED, after: $END_CURSOR) {
totalCount
pageInfo {
endCursor
hasNextPage
}
}
}
}\"}"
echo $QUERY
}
count_issues_by_label() {
LABEL=$1
TOTAL_COUNT=0
END_CURSOR="null"
while :; do
QUERY=$(fetch_issues "$LABEL" "$END_CURSOR")
RESPONSE=$(curl -s -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "$QUERY" https://api.github.com/graphql)
BUG_COUNT=$(echo $RESPONSE | jq '.data.repository.issues.totalCount')
if [ "$BUG_COUNT" != "null" ]; then
TOTAL_COUNT=$((TOTAL_COUNT + BUG_COUNT))
fi
HAS_NEXT_PAGE=$(echo $RESPONSE | jq '.data.repository.issues.pageInfo.hasNextPage')
END_CURSOR=$(echo $RESPONSE | jq -r '.data.repository.issues.pageInfo.endCursor')
if [ "$HAS_NEXT_PAGE" != "true" ]; then
break
fi
done
echo "$TOTAL_COUNT"
}
# Fetch counts for different labels
BUG_COUNT=$(count_issues_by_label "bug")
DOC_COUNT=$(count_issues_by_label "documentation")
ENHANCEMENT_COUNT=$(count_issues_by_label "enhancement")
mkdir -p public
echo "{
\"resolved_bugs\": $BUG_COUNT,
\"resolved_documentation\": $DOC_COUNT,
\"resolved_enhancements\": $ENHANCEMENT_COUNT
}" > public/spin-issue-count.json
- name: Check Git Status
run: |
git status
git diff
- name: Commit and Push Issue Counts
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add public/spin-issue-count.json
git commit -m "Update issue counts" || echo "No changes to commit"
git push