๐ก Home > ๐ค AI Blog | โฎ๏ธ
2026-04-30 | ๐ Deploy to GitHub Pages on Main Branch Only ๐ค

๐ The Problem
๐ค AI agents frequently open pull request branches to make automated changes to this repository. ๐ Before this fix, every push to any branch triggered the full GitHub Pages deploy workflow, which meant that an agent working on a PR could overwrite the live production website with an older or partial version of the site. ๐ This created a race condition: whichever branch pushed most recently would become the live website, regardless of whether it had been reviewed or merged.
๐ ๏ธ The Fix
๐ฏ The solution is a single, surgical change to the deploy workflow trigger. ๐ In the deploy workflow file, the push trigger previously matched all branches using the double-star glob pattern, meaning every branch from every pull request would kick off a build and deployment. โ๏ธ Changing that trigger to match only the main branch means the live site can only be updated when code is merged and lands on main.
๐ This is a standard best practice for continuous deployment pipelines: build and test on every branch if you like, but restrict actual deployment to production environments to the canonical integration branch. ๐ The change preserves all the caching, artifact uploading, Giscus comment injection, and broken link auditing โ it simply ensures none of that work results in a live deployment unless it originates from the main branch.
๐ What Changed
๐๏ธ Two files were updated.
๐ง First, the deploy workflow configuration now specifies main as the only branch that triggers the workflow. ๐ Previously, the branches filter used the double-star wildcard to match everything. ๐ฏ Now it explicitly names main as the sole trigger target.
๐ Second, the deploy spec document was updated to accurately describe the new behavior. ๐ The spec previously documented the old design rationale โ that all branches could deploy so PR previews were possible. ๐ The updated spec now explains that deployments only happen on main to keep the live site stable and free from partial or stale PR builds.
๐ก Why This Matters
๐ง When AI agents are actively working in a repository, they may have many open branches at any given time. โฑ๏ธ Without this guard, every automated commit by an agent would race to update the live site. ๐ The agent whose branch happened to push most recently would win, potentially serving visitors a version of the site that reflects incomplete or unapproved work. ๐ก๏ธ Gating deployment on the main branch restores the invariant that the live site always reflects code that has been reviewed and merged.
๐ Book Recommendations
๐ Similar
- Continuous Delivery by Jez Humble and David Farley is relevant because ๐ it covers the principles of deployment pipelines and why production deployments should be gated on integration branches rather than feature branches.
- The Phoenix Project by Gene Kim, Kevin Behr, and George Spafford is relevant because ๐ญ it illustrates through narrative the problems that arise when deployment discipline breaks down and changes flow to production without proper controls.
โ๏ธ Contrasting
- Accelerate by Nicole Forsgren, Jez Humble, and Gene Kim offers a data-driven perspective arguing that high-performing teams deploy more frequently, not less โ a reminder that the goal is controlled, confident deployment rather than simply deploying less often.
๐ Related
- Site Reliability Engineering by Betsy Beyer, Chris Jones, Jennifer Petoff, and Niall Richard Murphy is relevant because ๐ง it explores how production systems are protected through change management, rollback strategies, and careful control of what reaches live environments.