forked from DCC-EX/mkdocs-test
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (67 loc) · 2.62 KB
/
mkdocsbuild.yml
File metadata and controls
75 lines (67 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: mkdocs-build
on: push
jobs:
mkdocsbuild:
name: Build Mkdocs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install python requirements
run: |
mkdir venv
python3 -m venv venv
. ./venv/bin/activate
pip3 install -r requirements.txt
- name: Generated documentation from source
run: |
. pull_exrail.sh
- name: Build docu site
run: |
. ./venv/bin/activate
mkdocs build --strict
- name: Regression check code block line breaks
run: |
python3 - <<'PY'
from pathlib import Path
import re
import sys
html_path = Path("site/products/ex-commandstation/exrail/cookbooks/driving-trains/passing-loop/index.html")
css_path = Path("site/_static/css/dccex_theme.css")
if not html_path.exists():
print(f"Missing expected page: {html_path}")
sys.exit(1)
if not css_path.exists():
print(f"Missing expected stylesheet: {css_path}")
sys.exit(1)
html = html_path.read_text(encoding="utf-8")
css = css_path.read_text(encoding="utf-8")
# Ensure the first rendered code block is still multiline in generated HTML.
match = re.search(r'<div class="language-\w+ highlight"><pre><span></span><code>(.*?)</code></pre></div>', html, re.DOTALL)
if not match:
print("Could not locate a rendered fenced code block in passing-loop page")
sys.exit(1)
if "\n" not in match.group(1):
print("Rendered fenced code block no longer contains line breaks")
sys.exit(1)
# Ensure our CSS safeguard that preserves preformatted line breaks is present.
if "white-space: pre !important;" not in css:
print("Missing white-space safeguard for code blocks in compiled CSS")
sys.exit(1)
print("Regression checks passed: multiline code block and CSS safeguard present")
PY
- name: PreDeploy
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
run: |
BRANCH=$( echo "$GITHUB_REF" | sed 's,refs/heads/,,g')
mv site site2
mkdir site
mv site2 "site/$BRANCH"
- name: Deploy
if: github.event_name == 'push'
uses: oprypin/push-to-gh-pages@v3
with:
publish_dir: site
commit_message: ${{ github.event.head_commit.message }}
token: ${{ secrets.GITHUB_TOKEN }}
keep_files: true