Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 116 additions & 2 deletions .github/workflows/ghbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ jobs:
-e "GITHUB_REPOSITORY=${GITHUB_REPOSITORY}" \
-e "TS_CHECKOUT=${TS_CHECKOUT:-}" \
-e "TS_IG_BUILD=${TS_IG_BUILD:-}" \
ig-run python3 input/scripts/stamp_deploy.py output/index.html
ig-run python3 input/scripts/stamp_deploy.py output/index.html \
|| echo "⚠️ stamp_deploy.py exited with error (non-blocking)"

# ── Clean up the Docker container ──────────────────────────────────
# The ig-run container was kept alive for post-processing steps.
Expand All @@ -767,17 +768,72 @@ jobs:

# Fix output ownership so deploy actions (running on host) can read files
- name: Fix output directory ownership
if: success()
if: ${{ !cancelled() }}
run: sudo chown -R "$USER:$USER" ./output 2>/dev/null || true

# ── Branch index + history page ─────────────────────────────────────
# Fetches the list of deployed feature branches from gh-pages and:
# 1. Generates output/history.html (CI build history listing all branches)
# 2. Updates the ## Publication section of README.md with build URLs
# and a sorted feature-branch link table.
# README.md changes are committed back to the source branch when deploying
# from a non-PR push (only when the content actually changed, idempotent).
- name: Generate history page and update README branch links
if: ${{ !cancelled() }}
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ ! -f "input/scripts/update_branch_index.py" ]; then
echo "update_branch_index.py not found locally, downloading from smart-base repository..."
mkdir -p input/scripts
curl -L -f -o "input/scripts/update_branch_index.py" \
"${SCRIPTS_BASE_URL}/input/scripts/update_branch_index.py" \
2>/dev/null || echo "Failed to download update_branch_index.py"
fi
if [ -f "input/scripts/update_branch_index.py" ]; then
python3 input/scripts/update_branch_index.py \
|| echo "⚠️ update_branch_index.py exited with error (non-blocking)"
echo "✅ Branch index step complete"
else
echo "⚠️ update_branch_index.py not available, skipping"
fi

# ── Per-page CI build banner ─────────────────────────────────────────
# Injects a visible info box at the top of every HTML page in output/,
# showing the IG version, git commit SHA, and feature branch name.
- name: Inject CI build banner into output pages
if: ${{ !cancelled() }}
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GH_SHA: ${{ github.sha }}
IS_DEFAULT_BRANCH: ${{ env.IS_DEFAULT_BRANCH }}
run: |
if [ ! -f "input/scripts/inject_build_banner.py" ]; then
echo "inject_build_banner.py not found locally, downloading from smart-base repository..."
mkdir -p input/scripts
curl -L -f -o "input/scripts/inject_build_banner.py" \
"${SCRIPTS_BASE_URL}/input/scripts/inject_build_banner.py" \
2>/dev/null || echo "Failed to download inject_build_banner.py"
fi
if [ -f "input/scripts/inject_build_banner.py" ]; then
python3 input/scripts/inject_build_banner.py \
|| echo "⚠️ inject_build_banner.py exited with error (non-blocking)"
echo "✅ CI build banner step complete"
else
echo "⚠️ inject_build_banner.py not available, skipping"
fi

- name: Delete files >100MB before deployment
run: |
echo "Removing files over 100 MB from ./output..."
find ./output -type f -size +100M -print -delete

- name: Deploy candidate
id: deploy_candidate_1
uses: JamesIves/github-pages-deploy-action@v4.4.2
if: env.IS_DEFAULT_BRANCH == 'false' && inputs.deploy != false
continue-on-error: true
with:
branch: gh-pages # The branch the action should deploy to.
folder: ./output # The folder the action should deploy.
Expand All @@ -786,9 +842,22 @@ jobs:
single-commit: true
clean: false

- name: Deploy candidate (retry after gh-pages ref conflict)
uses: JamesIves/github-pages-deploy-action@v4.4.2
if: env.IS_DEFAULT_BRANCH == 'false' && inputs.deploy != false && steps.deploy_candidate_1.outcome == 'failure'
with:
branch: gh-pages
folder: ./output
commit-message: Deploy candidate branch (retry)
target-folder: branches/${{ env.BRANCH_DIR }}
single-commit: true
clean: false

- name: Deploy main
id: deploy_main_1
uses: JamesIves/github-pages-deploy-action@v4.4.2
if: env.IS_DEFAULT_BRANCH == 'true' && inputs.deploy != false
continue-on-error: true
with:
branch: gh-pages # The branch the action should deploy to.
folder: ./output # The folder the action should deploy.
Expand All @@ -798,6 +867,51 @@ jobs:
branches
sitepreview

- name: Deploy main (retry after gh-pages ref conflict)
uses: JamesIves/github-pages-deploy-action@v4.4.2
if: env.IS_DEFAULT_BRANCH == 'true' && inputs.deploy != false && steps.deploy_main_1.outcome == 'failure'
with:
branch: gh-pages
folder: ./output
commit-message: Deploy main branch (retry)
single-commit: true
clean-exclude: |
branches
sitepreview

# ── Commit updated README.md back to the source branch ──────────────
# Runs only when deploying from the default branch (not on PRs or
# feature-branch pushes) and only when README.md actually changed.
# Uses [skip ci] in the commit message to prevent a build loop.
- name: Commit README.md branch links update
if: env.IS_DEFAULT_BRANCH == 'true' && inputs.deploy != false
env:
GH_REPOSITORY: ${{ github.repository }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
if git diff --quiet README.md; then
echo "ℹ️ README.md unchanged — nothing to commit."
else
git add README.md
git commit -m "chore: update README.md with branch build links [skip ci]"
# Push with retry (up to 4 attempts, exponential back-off)
for i in 1 2 3 4; do
if git push; then
echo "✅ README.md pushed to branch."
break
fi
if [ "$i" -lt 4 ]; then
WAIT=$(( 2 ** i ))
echo "Push attempt $i failed, retrying in ${WAIT}s..."
sleep "$WAIT"
else
echo "⚠️ Could not push README.md after 4 attempts."
fi
done
fi

- name: Comment on PR - Deployment completed
if: steps.find_pr.outputs.IS_PR == 'true' && (success() || failure())
env:
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ As a convenience, this repository currently includes a comprehensive set of Digi
For detailed documentation on the DAK extraction functionality, see [input/scripts/README.md](input/scripts/README.md).

## Publication
Continuous Build: __http://WorldHealthOrganization.github.io/smart-base/index.html__
Canonical / permanent URL:
<br> </br>
<!-- CI_BUILD_LINKS_START -->
Continuous Build: [https://WorldHealthOrganization.github.io/smart-base/](https://WorldHealthOrganization.github.io/smart-base/)
Published: [https://smart.who.int/base](https://smart.who.int/base)

### Feature Branch Builds
_No feature branches deployed yet._
<!-- CI_BUILD_LINKS_END -->

This framework is published under a Creative Commons - IGO [license](LICENSE.md).

Expand Down
Loading
Loading