From a01232ac99a18488c26e93db92c240bc59f16e4c Mon Sep 17 00:00:00 2001 From: sethg Date: Fri, 12 Jun 2026 15:31:14 +0200 Subject: [PATCH 1/2] make ci_deploy_gh_pages.sh executable --- scripts/ci_deploy_gh_pages.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/ci_deploy_gh_pages.sh diff --git a/scripts/ci_deploy_gh_pages.sh b/scripts/ci_deploy_gh_pages.sh new file mode 100755 index 00000000000..e09d54da164 --- /dev/null +++ b/scripts/ci_deploy_gh_pages.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Deploys the main branch HTML build output to the gh-pages branch of the +# MapServer-documentation repo. Called from build.yml when a push to main +# is detected + +builddir=$1 +sha=$2 +github_token=$3 + +git config user.email "mapserverbot@mapserver.bot" +git config user.name "MapServer deploybot" + +git clone --no-checkout --depth=1 \ + https://x-access-token:${github_token}@github.com/mapserver/MapServer-documentation.git \ + /tmp/MapServer-documentation + +cd /tmp/MapServer-documentation +git checkout -B gh-pages + +# delete existing files +git rm -r * --quiet || true + +# add in the new build files +cp -rf "$builddir/html/"* . +touch .nojekyll + +git add -A +git commit -m "update with results of commit https://github.com/mapserver/MapServer-documentation/commit/$sha" --quiet || echo "Nothing to commit" +git push origin gh-pages --force \ No newline at end of file From 049ea41bc2284f30139db5eb4578ac47a26fda8c Mon Sep 17 00:00:00 2001 From: sethg Date: Fri, 12 Jun 2026 15:37:27 +0200 Subject: [PATCH 2/2] Build main docs and push to gh-pages branch --- .github/workflows/build.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a356ba42cb8..38baa94f89a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,8 @@ on: [push, pull_request, workflow_dispatch] jobs: build: runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout repository contents @@ -21,7 +23,8 @@ jobs: echo "GIT_BRANCH=$(echo $GITHUB_REF | cut -d '/' -f 3)" >> $GITHUB_ENV ./scripts/ci_build_docs.sh - - name: After success steps + # Deploy release branch to mapserver.github.io + - name: Deploy to mapserver.github.io if: ${{ success() && github.event_name == 'push' && github.repository == 'MapServer/MapServer-documentation' && github.ref_name == 'branch-8-6' }} run: | # setup the SSH key @@ -36,3 +39,11 @@ jobs: sha=$(git rev-parse --short ${{ github.sha }}) echo "publish website using $GIT_BRANCH branch and commit $sha" ./scripts/ci_deploy_website.sh build /tmp $sha + + # Deploy main branch to gh-pages branch (same repo) + - name: Deploy to gh-pages + if: ${{ success() && github.event_name == 'push' && github.repository == 'MapServer/MapServer-documentation' && github.ref_name == 'main' }} + run: | + sha=$(git rev-parse --short ${{ github.sha }}) + echo "Publishing main branch (commit $sha) to gh-pages" + ./scripts/ci_deploy_gh_pages.sh build $sha ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file