Skip to content

check-upstream

check-upstream #1

name: check-upstream
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
permissions:
contents: write
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check upstream (report latest SHA + TODO)
run: |
SHA=$(curl -s https://api.github.com/repos/colbymchenry/codegraph/commits/main | python3 -c 'import sys,json;print(json.load(sys.stdin)["sha"])')
echo "UPSTREAM_SHA=$SHA" >> $GITHUB_ENV
- name: Update site badge if changed
run: |
SHA="${{ env.UPSTREAM_SHA }}"
python3 - <<'EOF'
import re
p = 'index.html'
s = open(p, encoding='utf-8').read()
s = re.sub(r'main @ [0-9a-f]{7,40}', f'main @ {SHA[:7]}', s)
open(p, 'w', encoding='utf-8').write(s)
EOF
- name: Commit & push if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "no changes to commit"
else
git commit -m "chore(upstream): monthly check - refresh pinned SHA badge"
git push
fi