Repository navigation
116 lines (98 loc) · 3.33 KB
/
Copy pathdeploy_documentation.yml
File metadata and controls
116 lines (98 loc) · 3.33 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Simple workflow for deploying static content to GitHub Pages
name: Documentation
on:
push:
branches: [ "**" ]
tags: [ "v*" ]
pull_request:
branches:
- master
concurrency:
group: documentation-build-${{ github.repository }}
cancel-in-progress: false
permissions:
contents: write
pages: write
id-token: write
jobs:
ManyLinux_x86_64:
uses: MartinPdeS/MPSActions/.github/workflows/publish_documentation.yml@v5
with:
python-version: "3.11"
package-name: "SuPyMode"
apt-package: xvfb jq
deploy-pages: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
maintain_documentation:
needs: ManyLinux_x86_64
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
runs-on: ubuntu-latest
env:
DOCUMENTATION_BRANCH: documentation_page
steps:
- name: Checkout documentation branch
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
fetch-depth: 0
ref: ${{ env.DOCUMENTATION_BRANCH }}
- name: Install documentation landing page
run: |
set -Eeuo pipefail
git show "${GITHUB_SHA}:docs/redirect.html" > index.html
test -s docs/latest/index.html
- name: Rebuild version switcher
run: |
set -Eeuo pipefail
base_url="https://martinpdes.github.io/SuPyMode/docs"
mapfile -t versions < <(
find docs \
-mindepth 1 \
-maxdepth 1 \
-type d \
-printf "%f\n" \
| grep -v "^latest$" \
| sort -V -r
)
jq -n \
--arg base_url "${base_url}" \
--argjson versions "$(printf '%s\n' "${versions[@]}" | jq -R . | jq -s .)" \
'[
{
name: "latest",
version: "latest",
url: ($base_url + "/latest")
}
] + [
$versions[] | {
name: .,
version: .,
url: ($base_url + "/" + .)
}
]' > version_switcher.json
jq . version_switcher.json
- name: Commit documentation landing page
run: |
set -Eeuo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add index.html version_switcher.json
if git diff --cached --quiet; then
echo "Documentation landing page and version switcher are up to date."
exit 0
fi
git commit -m "Update documentation landing page and version switcher [skip ci]"
git push origin "HEAD:${DOCUMENTATION_BRANCH}"
- name: Upload GitHub Pages site
uses: actions/upload-pages-artifact@v3
with:
path: .
publish_pages:
needs: maintain_documentation
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy GitHub Pages site
id: deployment
uses: actions/deploy-pages@v4