|
| 1 | +name: Build and deploy site |
| 2 | + |
| 3 | +# Replaces the built-in "legacy" GitHub Pages build (Pages source: branch), which |
| 4 | +# builds server-side with the github-pages gem and is pinned to Jekyll 3.x — |
| 5 | +# ignoring this repo's Gemfile (jekyll ~> 4.3). Building here means local and |
| 6 | +# production use the same toolchain, and the build log is ours to read. |
| 7 | +# |
| 8 | +# Requires the repo's Pages source to be set to "GitHub Actions" |
| 9 | +# (Settings → Pages → Build and deployment → Source). Until that switch is made, |
| 10 | +# the `build` job still runs and validates, and `deploy` is the only part that |
| 11 | +# needs the new setting. |
| 12 | + |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches: [master] |
| 16 | + pull_request: |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +# Queue deployments rather than collapsing them. `cancel-in-progress: false` |
| 20 | +# matters here: the legacy builder silently folded one commit's deploy into an |
| 21 | +# in-flight build for an earlier commit, reported success, and left the site a |
| 22 | +# commit behind for four weeks. Queuing makes each commit get its own publish. |
| 23 | +concurrency: |
| 24 | + group: pages |
| 25 | + cancel-in-progress: false |
| 26 | + |
| 27 | +jobs: |
| 28 | + build: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + permissions: |
| 31 | + contents: read |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - uses: ruby/setup-ruby@v1 |
| 36 | + with: |
| 37 | + ruby-version: "3.3" |
| 38 | + bundler-cache: true |
| 39 | + |
| 40 | + - name: Build with Jekyll |
| 41 | + env: |
| 42 | + # Legacy Pages built with JEKYLL_ENV=production; keep that identical so |
| 43 | + # the switch doesn't quietly change rendered output. |
| 44 | + JEKYLL_ENV: production |
| 45 | + run: bundle exec jekyll build --trace |
| 46 | + |
| 47 | + - name: Upload artifact |
| 48 | + uses: actions/upload-pages-artifact@v3 |
| 49 | + # Defaults to ./_site |
| 50 | + |
| 51 | + deploy: |
| 52 | + needs: build |
| 53 | + # Only master publishes. Pull requests build and link-check but never deploy. |
| 54 | + if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' |
| 55 | + runs-on: ubuntu-latest |
| 56 | + permissions: |
| 57 | + pages: write |
| 58 | + id-token: write |
| 59 | + environment: |
| 60 | + name: github-pages |
| 61 | + url: ${{ steps.deployment.outputs.page_url }} |
| 62 | + steps: |
| 63 | + - name: Deploy to GitHub Pages |
| 64 | + id: deployment |
| 65 | + uses: actions/deploy-pages@v4 |
0 commit comments