Skip to content

Commit b29616c

Browse files
authored
Merge pull request #4 from sap-linuxlab/dev
Add combined GitHub Pages deploy with /preview from dev branch.
2 parents 995d161 + 504565e commit b29616c

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

.github/workflows/gh-pages.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
push:
77
branches:
88
- main
9+
- dev
910
pull_request:
1011
branches:
1112
- main
@@ -24,17 +25,38 @@ jobs:
2425
runs-on: ubuntu-latest
2526
steps:
2627
- uses: actions/checkout@v4
28+
with:
29+
ref: main
30+
path: src-main
31+
32+
- uses: actions/checkout@v4
33+
with:
34+
ref: dev
35+
path: src-dev
36+
2737
- uses: actions/setup-python@v5
2838
with:
2939
python-version: "3.12"
40+
3041
- run: pip install -r requirements.txt
31-
- run: mkdocs build --strict
42+
working-directory: src-main
43+
44+
- name: Build production
45+
working-directory: src-main
46+
run: mkdocs build --strict -d "${GITHUB_WORKSPACE}/site"
47+
48+
- name: Build preview
49+
working-directory: src-dev
50+
env:
51+
MKDOCS_PREVIEW: "1"
52+
run: mkdocs build --strict -d "${GITHUB_WORKSPACE}/site/preview"
53+
3254
- uses: actions/upload-pages-artifact@v3
3355
with:
3456
path: site
3557

3658
deploy:
37-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
59+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev')
3860
needs: build
3961
runs-on: ubuntu-latest
4062
environment:

hooks.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
import os
12
import shutil
23
from pathlib import Path
34

45

6+
def on_config(config, **kwargs):
7+
if os.environ.get("MKDOCS_PREVIEW") == "1":
8+
config.site_url = "https://sap-linuxlab.github.io/preview/"
9+
config.extra.pop("analytics", None)
10+
config.extra.pop("consent", None)
11+
12+
513
def on_post_build(config, **kwargs):
614
src = Path(".well-known")
715
if src.exists():

0 commit comments

Comments
 (0)