Add CI build banner and feature branch index generation#314
Conversation
…ect CI build banner
- Add update_branch_index.py: fetches deployed gh-pages branches via GitHub
API, generates output/history.html listing all feature branch builds, and
updates the ## Publication section of README.md with current build URLs
and a sorted branch-link table (idempotent, marker-delimited).
- Add inject_build_banner.py: post-processing script that injects a visible
CI build info box at the top of every HTML page in output/, showing the IG
version, short git commit SHA (linked to GitHub), and feature branch name
when building from a non-default branch.
- Update README.md: add CI_BUILD_LINKS markers and initial Publication links
(continuous build URL and published smart.who.int URL).
- Update ghbuild.yml: add three new steps that run after IG Publisher output
is available and before deployment:
1. Generate history page and update README branch links
2. Inject CI build banner into output pages
Plus a step after deployment to commit README.md changes back to the
default branch (with [skip ci] to prevent build loops).
https://claude.ai/code/session_01JTxo84uqnJ3S2xCTULCnw1
The IG Publisher already generates output/history.html as part of its standard publication pipeline. Rather than overwriting it, inject (or replace on re-runs) a "CI Feature Branch Builds" section just before </body>, demarcated with ci-branch-builds-start/end comment markers for idempotent updates. If history.html is not present (IG build skipped or failed) the step is silently skipped. https://claude.ai/code/session_01JTxo84uqnJ3S2xCTULCnw1
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
Regenerated via IG Publisher and extract_translations.py. Triggered by: litlfred
The IG Publisher generates <div id="publish-box"> (not <p id="publish-box">) as a sibling of <div id="segment-content">, not a child of it. New strategy: 1. Find the existing <div id="publish-box"> and append commit SHA / branch info as a <p> inside it — keeps everything in one yellow box. 2. Fallback: insert a standalone banner <div> just before segment-content. 3. Final fallback: insert after <body>. Also removes the incorrect <p id="publish-box"> and hl7-igpack-notice patterns that would never match the WHO template output. https://claude.ai/code/session_01JTxo84uqnJ3S2xCTULCnw1
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
Add || true to python script calls so that if either script exits non-zero the step still succeeds and the deploy step is not skipped. Rapid successive pushes have been cancelling builds before they could deploy; this ensures a partially-working build still publishes. https://claude.ai/code/session_01JTxo84uqnJ3S2xCTULCnw1
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
The IG Publisher renders the CI build notice as: <p id="publish-box">…</p> not a <div>, so the previous regex never matched and the script fell back to inserting a standalone banner above the yellow box. Changes: - Match <p id="publish-box"> (and <div> for forward-compat) by capturing the tag name from the regex match, then finding the matching close tag with str.find() — avoids the nested-element ambiguity of .*?</div>. - Change injected content from <p>…</p> to <br/><span>…</span> so it is valid HTML inside the existing <p> publish-box element. - Update the idempotent-removal regex to match <br/><span …> instead of <p …>. Result: commit SHA and branch name appear on a new line inside the existing yellow CI build notice box, not in a separate element above it. https://claude.ai/code/session_01JTxo84uqnJ3S2xCTULCnw1
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
…stead of success())
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
❌ Deployment FailedBranch: Deployment failed. Please check the build log for details. |
Two simultaneous builds can both attempt to force-push gh-pages, causing 'cannot lock ref' errors. Add continue-on-error + a retry step for both Deploy candidate and Deploy main to recover from this race condition automatically.
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
…duce one Without package-list.json the IG Publisher never writes output/history.html, causing a 404 for any build. Now update_branch_index.py creates a minimal standalone page (using the IG's own CSS) with the CI branch builds listing whenever the file is absent, so the URL is always valid.
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
The IG Publisher hard-codes the canonical publication URL in the publish-box and nav (e.g. href='https://smart.who.int/base/history.html'). For CI builds this sends the user to the wrong site. New rewrite_history_links() scans every HTML file in output/ and replaces those absolute hrefs (http or https) with a relative 'history.html', so both the publish-box and the Version History nav link point to the locally-generated CI history page.
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
Summary
This PR adds two new Python scripts to automatically manage CI build information across the generated IG documentation:
inject_build_banner.py— Injects a prominent banner into every HTML page showing the CI build status, IG version, git commit SHA, and feature branch name (when applicable)update_branch_index.py— Generates a feature branch index by fetching deployed branches from gh-pages and updating both the history.html page and README.md with current build linksThe workflow is updated to run these scripts as part of the GitHub Pages build process, with automatic commit-back of README.md changes to the source branch.
Key Changes
New script:
input/scripts/inject_build_banner.pyoutput/New script:
input/scripts/update_branch_index.pygh-pages/branches/via GitHub REST APIoutput/history.htmlto inject a "CI Feature Branch Builds" section with links## Publicationsection with current build URLs and a sorted feature branch tableGITHUB_TOKENto reduce API rate-limit riskUpdated
.github/workflows/ghbuild.yml[skip ci]tag)smart-baserepository if not present locallyUpdated
README.md<!-- CI_BUILD_LINKS_START -->and<!-- CI_BUILD_LINKS_END -->markers in the Publication sectionImplementation Details
GITHUB_REPOSITORY,GH_SHA,BRANCH_NAME, etc.)https://claude.ai/code/session_01JTxo84uqnJ3S2xCTULCnw1