Build every branch, deploy from the default branch
The `main`-only push trigger would never fire: this repository's default branch
is the one this work was pushed to, so the workflow — and therefore the Pages
deploy — sat idle. Build on every branch instead, and gate the deploy job on
`github.event.repository.default_branch` rather than a hard-coded name, so it
keeps working if the default is later renamed.
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 209b1f7..f70e09f 100644
--- a/.github/workflows/pages.yml
+++ b/.github/workflows/pages.yml
@@ -1,8 +1,9 @@
name: Build and deploy to Pages
on:
+ # Build every branch so a change is checked before it reaches the default
+ # branch; the deploy job below is what is gated.
push:
- branches: [main]
pull_request:
workflow_dispatch:
@@ -66,7 +67,9 @@ jobs:
deploy:
needs: build
- if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
+ # Deploy from whichever branch the repository calls default, rather than a
+ # hard-coded name.
+ if: github.ref_name == github.event.repository.default_branch && github.event_name != 'pull_request'
runs-on: ubuntu-latest
environment:
name: github-pages
diff --git a/README.md b/README.md
index 6772805..8c5cbd0 100644
--- a/README.md
+++ b/README.md
@@ -78,8 +78,11 @@ reason.
GitHub's hosted Jekyll build cannot run this site — it ignores `_plugins/` and
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`. Enable it
-under **Settings → Pages → Build and deployment → Source: GitHub Actions**.
+`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**.
## Using the CSS elsewhere