Repository navigation
223 lines (201 loc) · 8.6 KB
/
Copy pathci.yml
File metadata and controls
223 lines (201 loc) · 8.6 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# Copyright (c) 2026 WebCpp.org
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)
# The superproject's CI: the lanes, the own lanes, the docs, the lint, the tests of the tools and
# the report of library.yml, over every library of libs/ at the commit its submodule points to, and
# the index page with every library's page. Then:
#
# site b2 site builds the whole site into bin/site/ from those pages and the report, with
# the site's own pages (site/, webcpporg/webcpporg.github.io), and checks every link
# and every page's HTML, on every run; the build bin/site links to is the artifact
# site.
# publish on a push to main, commits the artifact site, b2 site's output as it is, with a
# .nojekyll, as the one commit of an orphan branch gh-pages and force-pushes that branch
# alone to webcpporg/webcpporg.github.io, whose Pages serve it at
# https://webcpporg.github.io/. gh-pages is build output, replaced whole. The push uses
# the deploy key of that repository, the secret SITE_DEPLOY_KEY.
# pages once publish has succeeded, deploys this repository's own Pages, the old address
# https://webcpporg.github.io/webcpp/, as tools/site/redirect.py's two pages, which
# send every path under /webcpp/ to the same path at the root, and carry noindex as
# every page of the preview does.
#
# The site is published whenever the pages were built, a red matrix included: the matrix is
# there to show what fails.
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
inputs:
prepare-environment:
description: Prepare and publish CI environments instead of running the test matrix.
type: boolean
default: false
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# A run on main publishes the site, and is never cut short by the next.
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
prepare-environment:
name: Prepare environments
if: >-
github.event_name == 'workflow_dispatch' && inputs.prepare-environment
&& github.repository == 'webcpporg/webcpp'
permissions:
contents: read
packages: write
uses: ./.github/workflows/prepare-environments.yml
ci:
name: CI
if: inputs.prepare-environment != true
uses: ./.github/workflows/library.yml
site:
name: Site
needs: ci
if: always() && needs.ci.outputs.docs == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
# The superproject with its submodules, the site's among them.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
submodules: true
- uses: ./tools/ci/actions/boost
- uses: ./tools/ci/actions/node
- name: Download the pages
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: docs
path: bin/pages
- name: Download the report
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: report
path: bin/report
# The pages and the report built already, so b2 site builds no doc of its own. b2 needs a
# toolset registered to load the project, though it compiles nothing here.
- name: b2 site
id: site
run: |
python3 tools/ci/matrix.py register clang-18
env -u CPATH -u CPLUS_INCLUDE_PATH -u C_INCLUDE_PATH \
b2 --user-config=.local/user-config.jam -a toolset=clang-18 site \
-sWEBCPP_SITE_DOCS=bin/pages -sWEBCPP_SITE_REPORT=bin/report
# bin/site is a link onto the build b2 site swapped in (tools/site/site.jam): the upload is
# given the build itself, never left to treat a link as its root.
echo "build=$(readlink -f bin/site)" >> "$GITHUB_OUTPUT"
# Every file b2 site wrote, a hidden one included, which upload-artifact leaves out by default.
- name: Upload the site
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: site
path: ${{ steps.site.outputs.build }}
include-hidden-files: true
if-no-files-found: error
retention-days: 7
# Only webcpporg/webcpp holds the deploy key: a fork's main publishes nothing. The commit needs
# no history of gh-pages, which it replaces whole, so the published repository is never
# fetched. The runs on main queue rather than cancel (concurrency, above), so an older site
# never replaces a newer one.
publish:
name: Publish
needs: site
if: >-
always() && needs.site.result == 'success' && github.event_name == 'push'
&& github.ref == 'refs/heads/main' && github.repository == 'webcpporg/webcpp'
runs-on: ubuntu-24.04
timeout-minutes: 15
concurrency:
group: publish
cancel-in-progress: false
defaults:
run:
shell: bash
steps:
- name: Download the site
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: site
path: ${{ runner.temp }}/site
# The key goes to a file of mode 600, made so by the umask before it holds anything, and no
# step prints it. GitHub's host key is the one it publishes (api.github.com/meta), so ssh
# trusts no host it has not been told of.
- name: Write the deploy key
env:
SITE_DEPLOY_KEY: ${{ secrets.SITE_DEPLOY_KEY }}
run: |
if [ -z "$SITE_DEPLOY_KEY" ]; then
echo "the secret SITE_DEPLOY_KEY, the deploy key of webcpporg/webcpporg.github.io, is not set"
exit 1
fi
umask 077
mkdir -p "$RUNNER_TEMP/ssh"
printf '%s\n' "$SITE_DEPLOY_KEY" > "$RUNNER_TEMP/ssh/deploy-key"
chmod 600 "$RUNNER_TEMP/ssh/deploy-key"
printf '%s\n' \
'github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl' \
> "$RUNNER_TEMP/ssh/known_hosts"
- name: Publish to webcpporg.github.io's gh-pages
env:
SHA: ${{ github.sha }}
run: |
site="$RUNNER_TEMP/site"
touch "$site/.nojekyll"
git -C "$site" init -q -b gh-pages
git -C "$site" add --all
git -C "$site" -c user.name="github-actions[bot]" \
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
-c commit.gpgsign=false commit -q -m "The preview of main at $SHA"
export GIT_SSH_COMMAND="ssh -i '$RUNNER_TEMP/ssh/deploy-key' -o IdentitiesOnly=yes \
-o UserKnownHostsFile='$RUNNER_TEMP/ssh/known_hosts' -o StrictHostKeyChecking=yes"
git -C "$site" push --force git@github.com:webcpporg/webcpporg.github.io.git \
refs/heads/gh-pages:refs/heads/gh-pages
- name: Remove the deploy key
if: always()
run: rm -rf "$RUNNER_TEMP/ssh"
# The old address redirects only once the site it sends readers to is published.
pages:
name: Pages
needs: publish
if: always() && needs.publish.result == 'success'
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
concurrency:
group: pages
cancel-in-progress: false
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: The redirect to https://webcpporg.github.io/
run: >-
python3 tools/site/redirect.py --to https://webcpporg.github.io/ --prefix /webcpp/
--out bin/redirect
# Each attempt of the run uploads its own artifact and deploys that one: a rerun's artifact
# stays beside the earlier attempts', and deploy-pages refuses a name two artifacts share.
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
name: github-pages-${{ github.run_attempt }}
path: bin/redirect
- uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
- name: Deploy
id: deploy
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
with:
artifact_name: github-pages-${{ github.run_attempt }}