Refresh site from GitHub API #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 site from GitHub API | |
| on: | |
| # Run daily at 06:13 UTC to pick up new repos / changed metadata. | |
| schedule: | |
| - cron: "13 6 * * *" | |
| # Run on demand from the Actions tab. | |
| workflow_dispatch: | |
| # Run whenever site.json changes (manual curation). | |
| push: | |
| paths: | |
| - "site.json" | |
| - "templates/**" | |
| - "scripts/**" | |
| permissions: | |
| contents: write | |
| jobs: | |
| refresh: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Build index.html | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: python scripts/build.py | |
| - name: Check for changes | |
| id: diff | |
| run: | | |
| if git diff --quiet index.html; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit refreshed index.html | |
| if: steps.diff.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add index.html | |
| git commit -m "chore: refresh index.html from GitHub API" | |
| git push |