-
Notifications
You must be signed in to change notification settings - Fork 1
176 lines (155 loc) · 5.71 KB
/
deploy.yml
File metadata and controls
176 lines (155 loc) · 5.71 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Deploy
on:
push:
branches:
- main
schedule:
- cron: 0 1 * * * # daily
workflow_dispatch:
concurrency:
group: pages
cancel-in-progress: true
jobs:
list-docs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.make-matrix.outputs.matrix }}
index_json: ${{ steps.make-matrix.outputs.index_json }}
hash: ${{ steps.check-hash.outputs.hash }}
changed: ${{ steps.check-hash.outputs.changed }}
env:
# This option controls which branches/tags are included in the documentation.
list_docs_options: -d master -m v4.3.1 -e v5.0.0-beta.1 -s
steps:
- name: Checkout the repository
uses: actions/checkout@v6
- name: Build docs index
id: make-matrix
run: |
./scripts/list-docs.sh ${{ env.list_docs_options }} >_index.json
cat _index.json
matrix="$(jq -c '{include: .docs}' _index.json)"
echo "matrix=$matrix" >>"$GITHUB_OUTPUT"
index_json="$(jq -cS . _index.json)"
echo "index_json=$index_json" >>"$GITHUB_OUTPUT"
echo "$index_json" >_index.json
- name: Compute hash and check if updated
id: check-hash
env:
hash: ${{ hashFiles('_index.json', 'scripts/make-docs.sh', 'scripts/update-index.sh', 'docs/_config.yml') }}
run: |
changed=true
git fetch --no-tags origin pages-state:refs/remotes/origin/pages-state 2>/dev/null || :
if git show origin/pages-state:.pages.hash >/dev/null 2>&1; then
old_hash=$(git show origin/pages-state:.pages.hash | tr -d '\r\n')
if [ "$hash" = "$old_hash" ]; then
changed=false
fi
fi
echo "changed=$changed" >>"$GITHUB_OUTPUT"
echo "hash=$hash" >>"$GITHUB_OUTPUT"
build-docs:
name: build-docs (${{ matrix.dir }})
needs: list-docs
runs-on: ubuntu-latest
outputs:
index_json: ${{ needs.list-docs.outputs.index_json }}
hash: ${{ needs.list-docs.outputs.hash }}
changed: ${{ needs.list-docs.outputs.changed }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.list-docs.outputs.matrix) }}
steps:
- name: Checkout the repository
uses: actions/checkout@v6
- name: Cache docs
id: cache-docs
uses: actions/cache@v5
with:
path: docs/${{ matrix.dir }}
key: docs-${{ matrix.dir }}-${{ matrix.ref }}-${{ matrix.dev }}-${{ hashFiles('scripts/make-docs.sh') }}
- name: Install dependencies
if: steps.cache-docs.outputs.cache-hit != 'true' && needs.list-docs.outputs.changed == 'true'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends doxygen-latex graphviz groff latex2html
- name: Build docs
if: steps.cache-docs.outputs.cache-hit != 'true' && needs.list-docs.outputs.changed == 'true'
run: ./scripts/make-docs.sh ${{ matrix.dev && '-d ' || '' }}${{ matrix.ref }} docs/${{ matrix.dir }}
- name: Upload docs artifact
if: needs.list-docs.outputs.changed == 'true'
uses: actions/upload-artifact@v7
with:
name: docs-${{ matrix.dir }}
path: |
docs/${{ matrix.dir }}
workaround/for/upload-artifact/issues/174 # See: https://github.com/actions/upload-artifact/issues/174
if-no-files-found: error
collect-docs:
needs: build-docs
if: needs.build-docs.outputs.changed == 'true'
runs-on: ubuntu-latest
outputs:
hash: ${{ needs.build-docs.outputs.hash }}
steps:
- name: Checkout the repository
uses: actions/checkout@v6
- name: Download all docs artifacts
uses: actions/download-artifact@v8
with:
merge-multiple: true
- name: Build docs index page
run: |
echo '${{ needs.build-docs.outputs.index_json }}' >_index.json
./scripts/update-index.sh _index.json docs
cat docs/index.md
- name: Configure GitHub Pages
uses: actions/configure-pages@v5
- name: Build site with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: docs
destination: _site
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: _site
deploy-docs:
needs: collect-docs
runs-on: ubuntu-latest
outputs:
hash: ${{ needs.collect-docs.outputs.hash }}
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
# Prerequisite: The following repository setting is required:
# Pages -> Build and deployment -> Source: GitHub Actions
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
update-state:
needs: deploy-docs
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout the repository
uses: actions/checkout@v6
- name: Update pages-state hash
run: |
git fetch --no-tags origin pages-state:refs/remotes/origin/pages-state 2>/dev/null || :
if git show-ref --verify --quiet refs/remotes/origin/pages-state; then
git switch -c pages-state --track origin/pages-state 2>/dev/null || git switch pages-state
else
git switch --orphan pages-state
fi
echo '${{ needs.deploy-docs.outputs.hash }}' >.pages.hash
git add .pages.hash
git -c user.name='github-actions[bot]' \
-c user.email='41898282+github-actions[bot]@users.noreply.github.com' \
commit -m 'chore(pages): update deployed hash' || true
git push origin pages-state