|
| 1 | +# Build the Jekyll site with GitHub Actions and deploy it to GitHub Pages. |
| 2 | +# |
| 3 | +# This replaces the default "deploy from a branch" GitHub Pages build (which |
| 4 | +# only runs whitelisted plugins and no custom build steps) with a full |
| 5 | +# `bundle exec jekyll build` running in CI. That unlocks custom plugins, |
| 6 | +# build-time code inlining, and content lint/test gates. See issue #98. |
| 7 | +# |
| 8 | +# IMPORTANT: this workflow only takes over publishing once the repo's |
| 9 | +# Pages "Source" is switched from "Deploy from a branch" to "GitHub Actions" |
| 10 | +# (Settings -> Pages -> Build and deployment -> Source). Until then it builds |
| 11 | +# but the deploy step will not publish. |
| 12 | +name: Build and deploy Jekyll site to Pages |
| 13 | + |
| 14 | +on: |
| 15 | + # Run on every push to the live branch. |
| 16 | + push: |
| 17 | + branches: ["main"] |
| 18 | + # Allow manual runs from the Actions tab. |
| 19 | + workflow_dispatch: |
| 20 | + |
| 21 | +# Minimum permissions the deploy job needs to publish to Pages. |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + pages: write |
| 25 | + id-token: write |
| 26 | + |
| 27 | +# Allow one concurrent deployment; don't cancel an in-progress production |
| 28 | +# deploy if another push lands while it's running. |
| 29 | +concurrency: |
| 30 | + group: "pages" |
| 31 | + cancel-in-progress: false |
| 32 | + |
| 33 | +jobs: |
| 34 | + build: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: Setup Ruby |
| 41 | + uses: ruby/setup-ruby@v1 |
| 42 | + with: |
| 43 | + # Matches .ruby-version. bundler-cache installs the Gemfile (still |
| 44 | + # the github-pages gem, so the build is byte-for-byte the current |
| 45 | + # one) and caches gems between runs. |
| 46 | + ruby-version: "3.3.11" |
| 47 | + bundler-cache: true |
| 48 | + cache-version: 0 |
| 49 | + |
| 50 | + - name: Setup Pages |
| 51 | + id: pages |
| 52 | + uses: actions/configure-pages@v5 |
| 53 | + |
| 54 | + - name: Build with Jekyll |
| 55 | + # base_path comes out as "/physcomp", matching baseurl in _config.yml. |
| 56 | + run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" |
| 57 | + env: |
| 58 | + JEKYLL_ENV: production |
| 59 | + |
| 60 | + - name: Upload artifact |
| 61 | + uses: actions/upload-pages-artifact@v3 |
| 62 | + |
| 63 | + deploy: |
| 64 | + needs: build |
| 65 | + runs-on: ubuntu-latest |
| 66 | + environment: |
| 67 | + name: github-pages |
| 68 | + url: ${{ steps.deployment.outputs.page_url }} |
| 69 | + steps: |
| 70 | + - name: Deploy to GitHub Pages |
| 71 | + id: deployment |
| 72 | + uses: actions/deploy-pages@v4 |
0 commit comments