Deploy Astro site to GitHub Pages #110
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: 'Deploy Astro site to GitHub Pages' | |
| on: | |
| # Rebuild daily after aaronparker/apptracker update-apps workflow has run. | |
| # update-hosted.yml runs at 11:00 UTC; update-apps.yml chains off it. | |
| # 13:00 UTC gives ~2 hours for the upstream data commit to complete. | |
| schedule: | |
| - cron: '0 13 * * *' | |
| # Also rebuild when source files or supported-apps.json are changed directly on main | |
| push: | |
| branches: ["main"] | |
| paths: | |
| - "src/**" | |
| - "public/**" | |
| - "astro.config.mjs" | |
| - "package.json" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 1 | |
| - name: Fetch app JSON data from aaronparker/apptracker | |
| run: | | |
| # Blobless sparse clone: downloads full commit history but only the | |
| # json/ directory blobs. This gives git log accurate lastUpdated dates | |
| # without downloading the rest of the repository content. | |
| git clone --filter=blob:none --sparse https://github.com/aaronparker/apptracker.git ${{ github.workspace }}/_appdata | |
| cd ${{ github.workspace }}/_appdata && git sparse-checkout set json | |
| mkdir -p ${{ github.workspace }}/json | |
| cp ${{ github.workspace }}/_appdata/json/*.json ${{ github.workspace }}/json/ | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci --force | |
| - name: Setup Pages | |
| id: pages | |
| uses: actions/configure-pages@v6 | |
| - name: Build with Astro | |
| run: npm run build | |
| env: | |
| NODE_ENV: production | |
| # Point git log at the cloned source repo so lastUpdated dates are | |
| # resolved from aaronparker/apptracker's commit history, not this repo. | |
| JSON_GIT_DIR: ${{ github.workspace }}/_appdata | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: dist/ | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 | |
| purge-cache: | |
| runs-on: ubuntu-latest | |
| needs: deploy | |
| steps: | |
| - name: Purge Cloudflare cache for appdata.json | |
| run: | | |
| curl -s -X POST \ | |
| "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE_ID }}/purge_cache" \ | |
| -H "Authorization: Bearer ${{ secrets.CF_API_TOKEN }}" \ | |
| -H "Content-Type: application/json" \ | |
| --data '{"files":["https://eucpilots.com/workbench/appdata.json"]}' \ | |
| | jq -e '.success' |