-
Notifications
You must be signed in to change notification settings - Fork 13.1k
69 lines (63 loc) · 2.77 KB
/
Copy pathstar-history.yml
File metadata and controls
69 lines (63 loc) · 2.77 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 star history chart
on:
push:
branches:
- main
# The job commits the regenerated SVGs back to main. Ignoring them here
# means the bot's own commit — which touches nothing else — cannot retrigger
# this workflow. (GitHub also declines to raise `push` events for commits
# made with GITHUB_TOKEN, so this is the second of two guards.)
paths-ignore:
- "assets/img/star-history-*.svg"
# Stars keep accruing even when nobody pushes, so refresh weekly regardless.
schedule:
- cron: "17 4 * * 1"
workflow_dispatch:
permissions:
contents: write
# Never let two runs race to commit the same files.
concurrency:
group: star-history
cancel-in-progress: false
jobs:
update:
runs-on: ubuntu-latest
# This repo is a template; without this guard every site generated from it
# would burn Actions minutes charting someone else's repository.
if: github.repository == 'alshedivat/al-folio'
steps:
- name: Checkout 🛎️
uses: actions/checkout@v6
- name: Regenerate chart 📈
env:
# Lifts the API limit from 60 to 5000 requests/hour. The stargazer
# data itself is public — no personal or scoped token is needed.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python3 bin/generate_star_history.py --repo "${{ github.repository }}" --out-dir assets/img
- name: Commit if changed 💾
run: |
set -euo pipefail
if git diff --quiet -- assets/img/star-history-light.svg assets/img/star-history-dark.svg; then
echo "Chart unchanged; nothing to commit."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add assets/img/star-history-light.svg assets/img/star-history-dark.svg
git commit -m "chore: refresh star history chart [skip ci]"
# Regenerating the chart takes about a minute, and update-tocs.yml
# triggers on the same push and commits to main in ~15s, so main can
# move underneath this job. That is a plain non-fast-forward, not a
# permissions problem, so rebase onto the new tip and retry instead of
# failing the run. Only the two generated SVGs are in flight here, and
# nothing else writes them, so the rebase cannot conflict in practice.
for attempt in 1 2 3; do
if git push; then
echo "Pushed on attempt ${attempt}."
exit 0
fi
echo "Push rejected (main moved); rebasing onto origin/main and retrying."
git pull --rebase origin main
done
echo "::error::Could not push the refreshed chart after 3 attempts."
exit 1