Skip to content

Add CI build banner and feature branch index generation#314

Merged
litlfred merged 10 commits intomainfrom
claude/update-readme-build-urls-W2FrH
Mar 19, 2026
Merged

Add CI build banner and feature branch index generation#314
litlfred merged 10 commits intomainfrom
claude/update-readme-build-urls-W2FrH

Conversation

@litlfred
Copy link
Collaborator

Summary

This PR adds two new Python scripts to automatically manage CI build information across the generated IG documentation:

  1. 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)
  2. 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 links

The 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.py

    • Idempotent banner injection into all HTML pages in output/
    • Displays IG version, commit SHA (linked to GitHub), and feature branch info
    • Intelligently places banner after existing CI notices or at the top of content
    • Skips non-page files (assets, CSS, JS, images, etc.)
  • New script: input/scripts/update_branch_index.py

    • Fetches deployed feature branches from gh-pages/branches/ via GitHub REST API
    • Post-processes output/history.html to inject a "CI Feature Branch Builds" section with links
    • Updates README.md ## Publication section with current build URLs and a sorted feature branch table
    • Idempotent: only writes files when content actually changes
    • Supports optional GITHUB_TOKEN to reduce API rate-limit risk
  • Updated .github/workflows/ghbuild.yml

    • Added step to generate history page and update README branch links
    • Added step to inject CI build banner into output pages
    • Added step to commit updated README.md back to source branch (default branch only, with [skip ci] tag)
    • Scripts are downloaded from smart-base repository if not present locally
  • Updated README.md

    • Added <!-- CI_BUILD_LINKS_START --> and <!-- CI_BUILD_LINKS_END --> markers in the Publication section
    • Placeholder content will be auto-populated with build URLs and feature branch links

Implementation Details

  • Both scripts use environment variables set by GitHub Actions (GITHUB_REPOSITORY, GH_SHA, BRANCH_NAME, etc.)
  • HTML injection uses regex patterns to find optimal insertion points and handles re-runs gracefully
  • GitHub API calls include proper error handling and informative logging
  • README.md updates are committed only when content changes (idempotent)
  • Feature branch links are sorted alphabetically for consistency

https://claude.ai/code/session_01JTxo84uqnJ3S2xCTULCnw1

…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
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


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
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 585efc2
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


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
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: ade4dae
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


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
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: f07fe74
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: cc02ee9
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

❌ Deployment Failed

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7

🔍 View Build Log


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.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: ff53398
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


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.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: ac83c91
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


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.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 9142186
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

✅ Deployment Successful

Branch: claude/update-readme-build-urls-W2FrH
Commit: 3ac2da7
Deployed to: https://WorldHealthOrganization.github.io/smart-base/branches/update-readme-build-urls-W2FrH

🌐 Open Preview
🔍 View Build Log


Deployment completed successfully! The site is now live at the URL above.

@litlfred litlfred merged commit 16aafb4 into main Mar 19, 2026
10 checks passed
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