Skip to content

Commit 3567a6f

Browse files
authored
Use GitHub pages (#117)
* Add support for tags in build workflow and fix regex in conf.py * Restructure build workflow to use github-pages * Fix syntax error in build.yaml * Add fetch-depth to checkout step in build.yaml * Fix fetch-depth in build.yaml * Fix variable assignment in build.yaml * Fix variable assignment in build.yaml. * Refactor build.yaml to simplify tag finding * Update conda activation command to use microconda * Update link-check job to use last tagged version instead of official
1 parent 249ee76 commit 3567a6f

2 files changed

Lines changed: 85 additions & 41 deletions

File tree

.github/workflows/build.yaml

Lines changed: 79 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ name: Build Tutorials
44
on:
55
push:
66
branches: [ master ]
7+
tags: ["*"]
78
pull_request:
89
branches: [ master ]
910
workflow_dispatch:
@@ -20,66 +21,108 @@ defaults:
2021

2122
jobs:
2223

23-
build-official-version:
24-
24+
find-tag:
2525
runs-on: ubuntu-latest
26-
26+
outputs:
27+
latest-tag: ${{ steps.find-tag.outputs.tag }}
2728
steps:
2829
- uses: actions/checkout@v4
2930
with:
3031
fetch-depth: 0
31-
32-
- name: Checkout last tagged
33-
run: |
34-
git checkout $(git describe --tags `git rev-list --tags --max-count=1`);
32+
33+
- id: find-tag
34+
run: echo "tag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> "$GITHUB_OUTPUT"
3535

36+
37+
link-check:
38+
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
3643
- name: Install mamba
3744
uses: mamba-org/setup-micromamba@v1
3845
with:
3946
environment-file: environment.yaml
40-
41-
- name: Build last tagged version
42-
run: |
43-
make clean
44-
make html O="-W"
4547

46-
- name: Check links
47-
run: sphinx-build -M linkcheck . _build -W --keep-going -a -q
48+
- run: sphinx-build -M linkcheck . _build -W --keep-going -a -q
49+
50+
51+
link-check-last-tagged:
4852

49-
- name: Deploy 🚀
50-
if: github.event.inputs.run_deploy
51-
uses: peaceiris/actions-gh-pages@v3
53+
runs-on: ubuntu-latest
54+
needs: find-tag
55+
steps:
56+
- uses: actions/checkout@v4
5257
with:
53-
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
54-
external_repository: AnyBody/tutorials
55-
publish_branch: gh-pages
56-
publish_dir: _build/html
58+
ref: ${{ needs.find-tag.outputs.latest-tag }}
59+
60+
- name: Install mamba
61+
uses: mamba-org/setup-micromamba@v1
62+
with:
63+
environment-file: environment.yaml
5764

65+
- run: sphinx-build -M linkcheck . _build -W --keep-going -a -q
66+
67+
68+
build:
5869

59-
sphinx-build:
6070
runs-on: ubuntu-latest
71+
needs: [find-tag, link-check]
72+
6173
steps:
6274
- uses: actions/checkout@v4
63-
75+
with:
76+
fetch-depth: 0
77+
6478
- name: Install mamba
6579
uses: mamba-org/setup-micromamba@v1
6680
with:
6781
environment-file: environment.yaml
68-
82+
6983
- name: Build Documentation
70-
run: make html O="-W"
84+
run: |
85+
sphinx-build -M html . _build-beta -W --keep-going -a -t draft
86+
87+
- name: Checkout last tagged
88+
run: |
89+
git checkout ${{ needs.find-tag.outputs.latest-tag }}
7190
72-
- name: Check links
73-
run: sphinx-build -M linkcheck . _build -W --keep-going -a -q
91+
- name: Build environment for last tagged version
92+
run: micromamba create -n tutorial-tagged -y -f environment.yaml
7493

75-
- name: Deploy 🚀
76-
uses: peaceiris/actions-gh-pages@v3
77-
if: github.ref == 'refs/heads/master'
78-
with:
79-
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
80-
external_repository: AnyBody/tutorials
81-
publish_branch: gh-pages
82-
publish_dir: _build/html
83-
destination_dir: dev
94+
- name: Build last tagged version
95+
run: |
96+
micromamba activate tutorial-tagged
97+
sphinx-build -M html . _build -W --keep-going -a
98+
99+
- name: Prepare html for upload
100+
run: |
101+
mkdir -p gh-pages/beta
102+
cp -rT _build-beta/html gh-pages/beta
103+
cp -rT _build/html gh-pages
104+
105+
- uses: actions/upload-pages-artifact@v2
106+
with:
107+
path: gh-pages
84108

85109

110+
deploy:
111+
needs: build
112+
if: github.ref == 'refs/heads/master'
113+
runs-on: ubuntu-latest
114+
permissions:
115+
pages: write
116+
id-token: write
117+
118+
environment:
119+
name: github-pages
120+
url: ${{ steps.deployment.outputs.page_url }}
121+
122+
steps:
123+
- name: Deploy to GitHub Pages
124+
id: deployment
125+
uses: actions/deploy-pages@v2
126+
127+
128+

conf.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ def tagged_commit():
129129
current_year = os.environ.get("YEAR", datetime.now().year)
130130

131131
ams_version = os.environ.get("AMS_VERSION", "7.4.3")
132-
if not re.match("^\d\.\d\.\d", ams_version):
132+
if not re.match(r"^\d\.\d\.\d", ams_version):
133133
raise ValueError("Wrong format for AMS version, environment variable")
134134
ams_version_short = ams_version.rpartition(".")[0]
135135
ams_version_x = ams_version_short + ".x"
136136

137137

138138
ammr_version = os.environ.get("AMMR_VERSION", "2.4.3")
139-
if not re.match("^\d\.\d\.\d", ammr_version):
139+
if not re.match(r"^\d\.\d\.\d", ammr_version):
140140
raise ValueError("Wrong format for AMMR version, environment variable")
141141
ammr_version_short = ammr_version.rpartition(".")[0]
142142

@@ -172,7 +172,7 @@ def tagged_commit():
172172
}
173173

174174

175-
no_index = """
175+
no_index = r"""
176176
.. meta::
177177
:name=robots content=noindex: \
178178
"""
@@ -448,10 +448,11 @@ def tagged_commit():
448448
]
449449

450450
linkcheck_allowed_redirects = {
451-
r"https://doi\.org.*": ".*",
451+
"https://doi.org.*": ".*",
452+
"https://dx.doi.org.*": ".*",
452453
r"https://www\.sphinx-doc\.org/": r"https://www\.sphinx-doc\.org/en/master/",
453454
r"https://www\.anybodytech\.com/anybody\.html\?fwd=.*": ".*",
454-
r"https://www\.youtube.com/.*": "https://consent\.youtube.com/.*",
455+
r"https://www\.youtube.com/.*": r"https://consent\.youtube.com/.*",
455456
}
456457

457458

0 commit comments

Comments
 (0)