Skip to content

Commit e5bedb8

Browse files
authored
Gh pages builds (#1087)
* make ci_deploy_gh_pages.sh executable * Build main docs and push to gh-pages branch
1 parent 15421ca commit e5bedb8

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on: [push, pull_request, workflow_dispatch]
55
jobs:
66
build:
77
runs-on: ubuntu-latest
8+
permissions:
9+
contents: write
810

911
steps:
1012
- name: Checkout repository contents
@@ -21,7 +23,8 @@ jobs:
2123
echo "GIT_BRANCH=$(echo $GITHUB_REF | cut -d '/' -f 3)" >> $GITHUB_ENV
2224
./scripts/ci_build_docs.sh
2325
24-
- name: After success steps
26+
# Deploy release branch to mapserver.github.io
27+
- name: Deploy to mapserver.github.io
2528
if: ${{ success() && github.event_name == 'push' && github.repository == 'MapServer/MapServer-documentation' && github.ref_name == 'branch-8-6' }}
2629
run: |
2730
# setup the SSH key
@@ -36,3 +39,11 @@ jobs:
3639
sha=$(git rev-parse --short ${{ github.sha }})
3740
echo "publish website using $GIT_BRANCH branch and commit $sha"
3841
./scripts/ci_deploy_website.sh build /tmp $sha
42+
43+
# Deploy main branch to gh-pages branch (same repo)
44+
- name: Deploy to gh-pages
45+
if: ${{ success() && github.event_name == 'push' && github.repository == 'MapServer/MapServer-documentation' && github.ref_name == 'main' }}
46+
run: |
47+
sha=$(git rev-parse --short ${{ github.sha }})
48+
echo "Publishing main branch (commit $sha) to gh-pages"
49+
./scripts/ci_deploy_gh_pages.sh build $sha ${{ secrets.GITHUB_TOKEN }}

scripts/ci_deploy_gh_pages.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Deploys the main branch HTML build output to the gh-pages branch of the
3+
# MapServer-documentation repo. Called from build.yml when a push to main
4+
# is detected
5+
6+
builddir=$1
7+
sha=$2
8+
github_token=$3
9+
10+
git config user.email "mapserverbot@mapserver.bot"
11+
git config user.name "MapServer deploybot"
12+
13+
git clone --no-checkout --depth=1 \
14+
https://x-access-token:${github_token}@github.com/mapserver/MapServer-documentation.git \
15+
/tmp/MapServer-documentation
16+
17+
cd /tmp/MapServer-documentation
18+
git checkout -B gh-pages
19+
20+
# delete existing files
21+
git rm -r * --quiet || true
22+
23+
# add in the new build files
24+
cp -rf "$builddir/html/"* .
25+
touch .nojekyll
26+
27+
git add -A
28+
git commit -m "update with results of commit https://github.com/mapserver/MapServer-documentation/commit/$sha" --quiet || echo "Nothing to commit"
29+
git push origin gh-pages --force

0 commit comments

Comments
 (0)