Keep the build independent of the Pages API
`actions/configure-pages` was failing the whole build on a repository where
Pages has never been enabled — first with "Get Pages site failed", then, with
`enablement: true`, with "Resource not accessible by integration": the workflow
token cannot create a Pages site. That turned a one-time settings step into a
red build on every branch, tests and all.
The action was only supplying `base_path`, which `_config.yml` already knows,
so drop it. The build now runs and validates the site anywhere, and only the
deploy job depends on Pages being switched on. Also assert every page in the
nav actually rendered, rather than just the index.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TL4uoCCvX2CqHWT8p3tLd7
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
index a6fac23..56eeebd 100644
--- a/.github/workflows/pages.yml
+++ b/.github/workflows/pages.yml
@@ -45,19 +45,14 @@ jobs:
- name: Test the token compiler
run: bundle exec rake test
- - name: Configure Pages
- id: pages
- uses: actions/configure-pages@v5
- with:
- # Turn Pages on for the repository if it is not already, rather than
- # failing the build until somebody visits the settings page. Needs
- # the `pages: write` permission granted above.
- enablement: true
-
+ # The baseurl comes from _config.yml rather than actions/configure-pages,
+ # so the build does not depend on the Pages API being reachable and stays
+ # green on branches and forks. Change it there if the site ever moves off
+ # a project page.
- name: Build
env:
JEKYLL_ENV: production
- run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
+ run: bundle exec jekyll build
- name: Check the build output
run: |
@@ -66,10 +61,22 @@ jobs:
grep -q -- '--ad-color-accent:' _site/assets/css/tokens.css
# A reference that failed to resolve would appear verbatim in the CSS.
! grep -Eq ':[[:space:]]*[a-z]+\.[a-z0-9]+;' _site/assets/css/tokens.css
+ # Every page in the nav should have been rendered.
+ for page in rationale install foundations/color foundations/typography \
+ foundations/space foundations/elevation foundations/motion \
+ components/button components/field components/badge \
+ components/callout components/card components/table \
+ components/tabs components/progress \
+ patterns/settings-form patterns/kitchen-sink; do
+ test -s "_site/$page/index.html" || { echo "missing $page"; exit 1; }
+ done
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
+ # Requires Pages to be set to "GitHub Actions" once, under
+ # Settings -> Pages -> Build and deployment. The workflow token is not
+ # permitted to turn that on for you.
deploy:
needs: build
# Deploy from whichever branch the repository calls default, rather than a
diff --git a/README.md b/README.md
index 8c5cbd0..23db9c4 100644
--- a/README.md
+++ b/README.md
@@ -81,8 +81,15 @@ pins its own Ruby — so `.github/workflows/pages.yml` builds it on Actions with
`ruby/setup-ruby` and uploads the result with `actions/deploy-pages`.
Every branch is built and tested; only the repository's default branch deploys.
-Enable the target under **Settings → Pages → Build and deployment → Source:
-GitHub Actions**.
+
+**One-time setup:** set **Settings → Pages → Build and deployment → Source** to
+**GitHub Actions**. The workflow token is not permitted to turn Pages on by
+itself, so the `deploy` job fails until this is done — the `build` job, tests
+included, runs regardless.
+
+The site's `baseurl` lives in `_config.yml` rather than coming from
+`actions/configure-pages`, which keeps the build independent of the Pages API.
+Change it there if the site ever moves off a project page.
## Using the CSS elsewhere