Skip to content

Update GitHub Profiles Cache #113

Update GitHub Profiles Cache

Update GitHub Profiles Cache #113

name: Update GitHub Profiles Cache
on:
schedule:
- cron: "0 6 * * *" # 06:00 UTC daily
workflow_dispatch:
push:
branches:
- main
paths:
- "blog/**"
- "blog/authors.yaml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
jobs:
update-profiles-cache:
name: Fetch and cache GitHub profiles
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: "24"
cache: npm
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
node-modules-${{ runner.os }}-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Restore existing profiles cache (for incremental updates)
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: static/data/github-profiles.json
key: github-profiles-v1-${{ github.run_id }}
restore-keys: |
github-profiles-v1-
- name: Fetch GitHub profiles
# --force ensures a full refresh on the scheduled/push run so company,
# sponsorable, and donation fields stay current, not just delta-patched.
env:
GITHUB_TOKEN: ${{ github.token }}
run: node scripts/fetch-github-profiles.js --force
- name: Validate profiles output
run: |
count=$(node -e "const d=require('./static/data/github-profiles.json'); console.log(Object.keys(d).length)")
echo "Profiles in cache: $count"
if [ "$count" -lt 50 ]; then
echo "::error::Profile count ($count) is suspiciously low — aborting cache save"
exit 1
fi
- name: Save GitHub profiles cache
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: static/data/github-profiles.json
key: github-profiles-v1-${{ github.run_id }}