Refresh WWDC data #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Refresh WWDC data | |
| on: | |
| schedule: | |
| # Daily at 02:00 UTC. During WWDC week (early-mid June) new sessions | |
| # publish throughout the week, so this keeps the dataset within ~24h. | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| year: | |
| description: 'WWDC year (e.g. 2025). Leave blank to refresh all years already under data/.' | |
| required: false | |
| default: '' | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: refresh-wwdc-data | |
| cancel-in-progress: false | |
| jobs: | |
| refresh: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Refresh requested year (workflow_dispatch) | |
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.year != '' }} | |
| env: | |
| YEAR: ${{ inputs.year }} | |
| run: | | |
| set -euo pipefail | |
| short="wwdc${YEAR: -2}" | |
| mkdir -p "data/${short}" | |
| node ./bin/wwdc-quick-look.js crawl --year "${YEAR}" --locale en \ | |
| --out-dir "data/${short}" --concurrency 8 | |
| - name: Refresh all years already under data/ (default) | |
| if: ${{ github.event_name != 'workflow_dispatch' || inputs.year == '' }} | |
| run: | | |
| set -euo pipefail | |
| shopt -s nullglob | |
| found=0 | |
| for dir in data/wwdc*; do | |
| [ -d "$dir" ] || continue | |
| short=$(basename "$dir") | |
| year="20${short: -2}" | |
| echo "Refreshing ${short} (year ${year})" | |
| node ./bin/wwdc-quick-look.js crawl --year "${year}" --locale en \ | |
| --out-dir "${dir}" --concurrency 8 | |
| found=$((found + 1)) | |
| done | |
| if [ "$found" -eq 0 ]; then | |
| echo "No data/wwdc* directories present; nothing to refresh." | |
| fi | |
| - name: Rebuild data/index.json | |
| run: node scripts/build-index.mjs | |
| - name: Commit and push if 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 data/ | |
| if git diff --cached --quiet; then | |
| echo "No dataset changes to commit." | |
| exit 0 | |
| fi | |
| stamp=$(date -u +%Y-%m-%dT%H:%MZ) | |
| git commit -m "chore(data): refresh WWDC dataset ${stamp}" | |
| git push |