Repository navigation
66 lines (56 loc) · 2.1 KB
/
Copy pathrefresh-stats.yml
File metadata and controls
66 lines (56 loc) · 2.1 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
name: Refresh GitHub stats
# Pulls fresh stars / forks / last-push for every catalog entry every day and
# commits the result directly to main. No PR — stats are low-risk numeric data
# that nobody needs to review.
#
# When a dedicated bot account exists (e.g. backblaze-b2-bot), set BOT_NAME /
# BOT_EMAIL vars and LABS_DISCOVERY_PAT for API reads. Pushes use GITHUB_TOKEN
# so the workflow can explicitly queue exactly one deploy after committing.
on:
schedule:
- cron: "0 7 * * *" # 07:00 UTC every day
workflow_dispatch:
permissions:
actions: write
contents: write
concurrency:
group: refresh-stats
cancel-in-progress: false
jobs:
refresh:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ github.token }}
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
cache: "npm"
- run: npm ci
- name: Sync GitHub stats
env:
GH_TOKEN: ${{ secrets.LABS_DISCOVERY_PAT || secrets.GITHUB_TOKEN }}
run: npm run sync-stats
- name: Commit and push if changed
id: commit
env:
GIT_AUTHOR_NAME: ${{ vars.BOT_NAME || 'github-actions[bot]' }}
GIT_AUTHOR_EMAIL: ${{ vars.BOT_EMAIL || '41898282+github-actions[bot]@users.noreply.github.com' }}
run: |
if [[ -z "$(git status --porcelain src/data/github-stats.json)" ]]; then
echo "No changes — nothing to commit."
echo "committed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
git config user.name "$GIT_AUTHOR_NAME"
git config user.email "$GIT_AUTHOR_EMAIL"
git add src/data/github-stats.json
git commit -m "chore(stats): refresh github-stats.json"
git push
echo "committed=true" >> "$GITHUB_OUTPUT"
- name: Deploy site if stats changed
if: steps.commit.outputs.committed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run deploy.yml --ref main