Repository navigation
63 lines (53 loc) · 1.9 KB
/
Copy pathcontribution-city.yml
File metadata and controls
63 lines (53 loc) · 1.9 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
name: contribution city
on:
schedule:
# 03:17 UTC daily — an odd minute, since the top of the hour is congested
- cron: "17 3 * * *"
workflow_dispatch:
push:
branches: [main]
paths:
- ".github/scripts/contribution_city.py"
- ".github/workflows/contribution-city.yml"
permissions:
contents: write
concurrency:
group: contribution-city
cancel-in-progress: false
jobs:
redraw:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Redraw the city
env:
# CITY_TOKEN is an optional PAT with the read:user scope; it also
# counts private contributions. Without it the default token draws
# public contributions only.
GH_TOKEN: ${{ secrets.CITY_TOKEN || secrets.GITHUB_TOKEN }}
run: |
python .github/scripts/contribution_city.py \
--login "${{ github.repository_owner }}" \
--out assets/contribution-city.svg
- name: Commit if the skyline changed
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add assets/contribution-city.svg
# Compare the index against HEAD, not the working tree. A plain
# `git diff -- <path>` ignores untracked files, so on the very first
# run it reports "no change" and the new SVG is silently thrown away.
if git diff --cached --quiet -- assets/contribution-city.svg; then
echo "skyline unchanged, nothing to commit"
exit 0
fi
git commit -m "chore: redraw contribution city"
git push || {
# someone pushed while we were drawing
git pull --rebase origin main
git push
}