Skip to content

Publish the site with GitHub Pages from the workflow, without the gh-pages branch - #155

Open
wl-estensd wants to merge 1 commit into
masterfrom
ci/pages-artifact-deploy
Open

wl-estensd wants to merge 1 commit into
masterfrom
ci/pages-artifact-deploy

Conversation

@wl-estensd

Copy link
Copy Markdown
Contributor

This PR builds on #154 and should be merged after it. Its base is the branch of #154, so the diff only shows the changes of this PR.

Merging this needs one change in the repository settings by an admin. See "How to roll this out" below.

Why

Today the workflow pushes the finished website to the gh-pages branch, and GitHub Pages serves that branch. This PR changes to the way GitHub recommends for new sites: the workflow hands the built site directly to GitHub Pages.

  • There is no gh-pages branch that looks "600 commits behind" and can be merged or deleted by mistake.
  • The site (about 400 MB with images and PDFs) is no longer pushed into the repository at every deploy.
  • The workflow no longer needs write access to the repository contents.
  • Each deploy shows under Environments (github-pages) with its history.

What changed

  • Build job: the ghp-import push is replaced by actions/upload-pages-artifact v5.0.0, which uploads the site/ directory that was built and checked in the steps before. Its permission goes from contents: write to contents: read.
  • New deploy job: actions/deploy-pages v5.0.1 publishes that upload. It has pages: write and id-token: write, and uses the github-pages environment.
  • Both only run on master, as before. Nothing is rebuilt between the checks and the publish.
  • README.md: one sentence about how the site is published.

The published content is the same as today. The CNAME and .nojekyll files are no longer written, because they are only used by the branch way.

How to roll this out

A repository admin has to change one setting: Settings -> Pages -> Build and deployment -> Source: "GitHub Actions" (today it is "Deploy from a branch", gh-pages).

Suggested order, to keep the time between the two changes short:

  1. Merge this PR. The build job passes. The deploy job is expected to fail, because Pages is still set to the branch. The live site is not touched and keeps showing the last deploy.
  2. The admin changes the Source setting to "GitHub Actions".
  3. Re-run the failed deploy job on that workflow run ("Re-run failed jobs"). It publishes the site that the build job already uploaded. The upload is kept for 1 day.
  4. Check https://docs.waterlinked.com and that the custom domain docs.waterlinked.com is still shown on the Pages settings page.
  5. When everything works, the gh-pages branch can be deleted. Keep it for a few days first: switching the Source setting back to the branch is the rollback.

Checked

  • The github-pages environment already allows deploys from master (allowed branches: gh-pages and master).
  • The Pages settings already have the custom domain docs.waterlinked.com with HTTPS enforced.
  • The workflow passes actionlint, and the run on this branch passes (the upload and deploy only run on master, so they are skipped here).

Not tested

  • The upload and the deploy themselves. They can only run on master, and the deploy needs the settings change.
  • That the deploy job fails cleanly in step 1 while the Source is still the branch, and that the custom domain stays set after the Source change. Both are what the GitHub documentation describes, but they have not been tried on this repository.

🤖 Generated with Claude Code

…pages branch

The build job uploads the built and checked site/ directory as a Pages
artifact. A new deploy job publishes that artifact with actions/deploy-pages.
Both only run on master.

- The site is no longer pushed to the gh-pages branch.
- The workflow no longer needs write access to the repository contents. The
  build job has contents: read, the deploy job has pages: write and
  id-token: write.
- Each deploy shows under Environments (github-pages) on GitHub.

This needs a change in the repository settings by an admin:
Settings -> Pages -> Source must be set to "GitHub Actions".

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Base automatically changed from ci/update-actions to master November 25, 2026 12:59

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant