-
Notifications
You must be signed in to change notification settings - Fork 2
69 lines (54 loc) · 1.89 KB
/
Copy pathupdates.yaml
File metadata and controls
69 lines (54 loc) · 1.89 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
name: Update Stats
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Setup Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417
with:
go-version: "1.25"
- name: Fetch workflow data
run: |
gh api repos/urunc-dev/urunc/actions/workflows \
--paginate > workflows_raw.json
echo "{}" > runs_raw.json
jq -r '.workflows[] | "\(.id)\t\(.name)"' workflows_raw.json | while IFS=$'\t' read -r wf_id wf_name; do
echo "Processing workflow: $wf_name (ID: $wf_id)"
gh api "repos/urunc-dev/urunc/actions/workflows/${wf_id}/runs?per_page=20" \
> runs_tmp.json
jq --arg id "$wf_id" \
--arg name "$wf_name" \
--slurpfile runs runs_tmp.json \
'. + {($id): ($runs[0] + {name: $name})}' \
runs_raw.json > tmp.json
mv tmp.json runs_raw.json
done
echo "===== FINAL workflows_raw.json ====="
cat workflows_raw.json
echo "===== FINAL runs_raw.json ====="
cat runs_raw.json
rm -f runs_tmp.json
- name: Generate stats
run: go run .
- name: Cleanup temp files
run: rm -f workflows_raw.json runs_raw.json tmp.json
- name: Commit changes if needed
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add stats.json
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "update stats"
git push