Build and Deploy to GitHub Pages #759
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: Build and Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| schedule: | |
| # Rebuild future-dated posts after their UTC date becomes eligible. | |
| # GitHub schedules may be delayed; avoid the top-of-hour queue. | |
| - cron: '17 10 * * *' | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | |
| - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 | |
| with: | |
| version: 10 | |
| - name: Setup Node | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7 | |
| with: | |
| node-version: '22' | |
| cache: 'pnpm' | |
| cache-dependency-path: astro-site/pnpm-lock.yaml | |
| - name: Install dependencies | |
| run: cd astro-site && pnpm install --frozen-lockfile | |
| - name: Cache Astro font downloads (issue #408 — avoid transient jsdelivr fetch) | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: astro-site/node_modules/.astro/fonts | |
| key: astro-fonts-${{ hashFiles('astro-site/astro.config.mjs', 'astro-site/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| astro-fonts- | |
| - name: Build site | |
| run: cd astro-site && pnpm build | |
| env: | |
| NODE_ENV: production | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 | |
| with: | |
| path: astro-site/dist/ | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 |