Skip to content

Deploy the site on every push to main - #22

Open
evertonfraga wants to merge 1 commit into
mainfrom
chore/pages-deploy-on-push
Open

evertonfraga wants to merge 1 commit into
mainfrom
chore/pages-deploy-on-push

Conversation

@evertonfraga

Copy link
Copy Markdown
Contributor

Summary

Makes Deploy site to Pages the site's only deployer, run on every push to main, and fails it when the published site is not the one it built.

Repository setting (already applied)

The Pages source was a branch (main:/docs), so GitHub's built-in pages-build-deployment also rebuilt the site from that folder on every push. Its Jekyll render has no root index.html (the generated pages are gitignored), so it replaced the landing page with a 404 until the workflow was run by hand.

I set the source to "GitHub Actions" (gh api -X PUT repos/strata-org/Strata-Solidity/pages -f build_type=workflow). The live site still serves (200). Revert with -f build_type=legacy if needed.

.github/workflows/deploy-pages.yml

  • Runs on pushes to main that change docs/site/**, docs/guide/src/** or the workflow itself, and still on demand.
  • After deploying, waits until the live site serves this run's commit at /build.txt, then checks that the root and docs/index.html serve the site.
  • Moves the actions to their current majors: checkout@v7, setup-python@v7, configure-pages@v6, upload-pages-artifact@v5, deploy-pages@v5. The previous run warned that the old ones target Node 20, which is deprecated.
  • Installs the build dependencies from docs/site/requirements.txt.

Other files

  • docs/site/requirements.txt (new): pins markdown==3.11 and pygments==2.19.2; ci.yml's site build uses it too.
  • docs/site/README.md: describes the push trigger and the required Pages source, instead of saying Pages is not enabled.
  • docs/site/.gitignore: ignores the generated build.txt.

Testing

  • Both workflows parse; the deploy workflow's triggers and steps are as listed above.
  • The site builds with the pinned dependencies (landing page and 16 guide pages).
  • The check step, run outside Actions: exits 0 against a local server that serves the expected commit and pages; exits 1 when the root is missing, and when the live site serves a different commit.
  • Not tested: the deploy job itself. The github-pages environment only allows deployments from main, so it first runs when this merges. I'll check that run, and that pages-build-deployment no longer runs on that push.

The site was deployed only when someone ran the workflow by hand, so the
published pages lagged main. Meanwhile the repository's Pages source was a
branch (main:/docs), so GitHub's built-in pages-build-deployment rebuilt
the site from that folder on every push. Its Jekyll render has no root
index.html (the generated site is gitignored), which replaced the landing
page with a 404 until the workflow was run again.

The Pages source is now "GitHub Actions" (a repository setting, changed
separately), so this workflow is the only deployer. It runs on pushes to
main that change docs/site or docs/guide/src, and still on demand.

After deploying, it waits until the live site serves this run's commit
(/build.txt) and then checks that the root and the guide index serve the
site, so a broken deployment fails the run instead of going unnoticed.

Also:
- actions bumped to their current majors (Node 24); the old ones warned
  that Node 20 is deprecated
- the build dependencies are pinned in docs/site/requirements.txt, used
  by this workflow and by CI's site build
- docs/site/README.md and the workflow no longer say Pages is not enabled

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