-
Notifications
You must be signed in to change notification settings - Fork 2
159 lines (141 loc) · 4.98 KB
/
publish-doc.yml
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# action.yml
name: 'Build Docs'
on:
push:
branches:
- main
# - develop
release:
types: [published]
jobs:
build_docs:
runs-on: ubuntu-latest
name: 'Build Sphinx documentation'
steps:
- name: 'Checkout the repo'
uses: actions/checkout@v4
- name: 'Run the buildscript'
# Workaround to keep tty working
# https://github.com/gfx/example-github-actions-with-tty
shell: 'script -q -e -c "bash {0}"'
run: ./docs/build-docs.sh ${{ fromJSON('{"tag":"html","branch":"html-dev"}')[github.ref_type] }}
# Cache the build so we can deploy it
- name: 'cache built docs'
id: cache-build
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/docs/build/html
key: ${{ github.sha }}-docs
# Cache version generation script if we are on a tag
- name: 'cache version generation script'
id: cache-version-script
uses: actions/cache/save@v4
if: github.ref_type == 'tag'
with:
path: ${{ github.workspace }}/docs/generate_versions.sh
key: ${{ github.sha }}-docs
deploy_main_docs:
permissions:
contents: write
pages: write
runs-on: ubuntu-latest
name: 'Publish latest docs to github pages'
needs: build_docs
if: github.ref_type == 'branch' && github.ref == 'refs/heads/main'
steps:
- name: 'Restore built docs cache'
uses: actions/cache/restore@v4
id: restore-build
with:
path: ${{ github.workspace }}/docs/build/html
key: ${{ github.sha }}-docs
- name: 'Deploy to gh-pages'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build/html
publish_branch: gh-pages
destination_dir: dev
deploy_version_docs:
permissions:
contents: write
pages: write
runs-on: ubuntu-latest
name: 'Publish versioned documentation to github pages'
needs: build_docs
if: github.ref_type == 'tag'
steps:
- name: 'Checkout the repo'
uses: actions/checkout@v4
with:
ref: gh-pages
path: ./public
- name: 'Get cached version script'
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/docs/generate_versions.sh
key: ${{ github.sha }}-docs
- name: 'Get cached version build'
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/docs/build/html
key: ${{ github.sha }}-docs
- name: 'Move file & directories & run version update script'
shell: 'script -q -e -c "bash {0}"'
run: >
mv ./docs/generate_versions.sh ./public/generate_versions.sh
&& mv ./docs/build/html ./public/${{ github.ref_name }}
&& rm -rf ./docs/
&& ./public/generate_versions.sh
&& rm -f ./public/generate_versions.sh
- name: 'Update latest symlink and kill git'
shell: 'script -q -e -c "bash {0}"'
run: cd ./public/ && ln -sfn ./${{ github.ref_name }} ./latest && ls -la
# - name: 'Deploy to gh-pages'
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./public
# publish_branch: gh-pages
- name: 'Manually deploy to gh-pages'
run: |
git config --global user.email "${{github.actor}}@users.noreply.github.com"
git config --global user.name "${{github.actor}}"
cd ./public
git add .
git commit -m "deploy: ${{ github.sha }}" && git push origin gh-pages
# deploy_develop_docs:
# permissions:
# contents: write
# pages: write
# runs-on: ubuntu-latest
# name: 'Publish development documentation to github pages'
# needs: build_docs
# if: endsWith(github.ref, '/develop')
# steps:
# - name: 'Restore built docs cache'
# uses: actions/cache/restore@v3
# id: restore-build
# with:
# path: ${{ github.workspace }}/docs/build/html
# key: ${{ github.sha }}-docs
# - name: 'Deploy to gh-pages'
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./docs/build/html
# publish_branch: gh-pages
# destination_dir: develop
# Probably not necesary with cache
# cleanup:
# runs-on: ubuntu-latest
# needs: ['build_docs', 'deploy_main_docs', 'deploy_develop_docs']
# name: 'cache cleanup'
# if: always() && needs.build_docs.result == 'success'
# # Fun trick to say we need the above to all finish but only care about the first success
# steps:
# - uses: adapttive/[email protected]
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# cache-key: ${{ github.sha }}-docs
# TODO Versioned docs (look into the release event)