Repository navigation
160 lines (141 loc) · 5.63 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
160 lines (141 loc) · 5.63 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
name: Deploy Docs to GitHub Pages
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Published release tag to deploy, for example v3.0.0'
required: true
type: string
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout release
uses: actions/checkout@v5
with:
ref: ${{ inputs.release_tag }}
path: release
- name: Checkout release tooling
uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
path: tooling
- name: Verify tag, package and npm registry agree
shell: bash
run: |
RELEASE_TAG='${{ inputs.release_tag }}'
if [[ ! "${RELEASE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::release_tag must be an exact stable SemVer tag such as v3.0.0"
exit 1
fi
PACKAGE_VERSION=$(node -p "require('./release/package.json').version")
TAG_VERSION=${RELEASE_TAG#v}
REGISTRY_VERSION=$(npm view "monsqlize@${PACKAGE_VERSION}" version --registry=https://registry.npmjs.org/)
if [ "${TAG_VERSION}" != "${PACKAGE_VERSION}" ] || [ "${REGISTRY_VERSION}" != "${PACKAGE_VERSION}" ]; then
echo "::error::tag=${TAG_VERSION}, package=${PACKAGE_VERSION}, registry=${REGISTRY_VERSION} must match"
exit 1
fi
echo "DOCS_RELEASE_VERSION=${PACKAGE_VERSION}" >> "${GITHUB_ENV}"
echo "DOCS_RELEASE_CHANNEL=stable" >> "${GITHUB_ENV}"
- name: Select verified website toolchain
shell: bash
run: |
if node -e "process.exit(require('./release/website/package.json').scripts?.['check:browser'] ? 0 : 1)"; then
echo "DOCS_LEGACY_TAG=false" >> "${GITHUB_ENV}"
else
cp tooling/website/package.json release/website/package.json
cp tooling/website/package-lock.json release/website/package-lock.json
echo "DOCS_LEGACY_TAG=true" >> "${GITHUB_ENV}"
fi
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: release/website/package-lock.json
- name: Check docs example matrix
run: node release/scripts/validation/check-doc-example-matrix.cjs --require-covered
- name: Include site ownership verification
shell: bash
run: |
node <<'NODE'
const fs = require('node:fs');
const { execFileSync } = require('node:child_process');
const file = 'google4524eb8336ad041b.html';
const source = `tooling/docs/public/${file}`;
const sourceSha = execFileSync('git', ['-C', 'tooling', 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
if (sourceSha !== process.env.GITHUB_SHA) {
throw new Error('Verification source must match the workflow commit.');
}
if (fs.readFileSync(source, 'utf8').trimEnd() !== `google-site-verification: ${file}`) {
throw new Error('Unexpected Google site verification content.');
}
// Site ownership is independent of the published documentation version.
fs.copyFileSync(source, `release/docs/public/${file}`);
fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY,
`\nSite verification file: ${file}\n\nVerification source commit: ${sourceSha}\n`);
NODE
- name: Install website dependencies
working-directory: ./release/website
run: npm ci
- name: Install Chromium for current-site verification
if: env.DOCS_LEGACY_TAG != 'true'
working-directory: ./release/website
run: npx playwright install --with-deps chromium
- name: Verify docs site
working-directory: ./release/website
shell: bash
run: |
if [[ "${DOCS_LEGACY_TAG}" != "true" ]]; then
npm run verify
else
npm run build
node ../../tooling/scripts/validation/check-site-links.cjs --dist "${PWD}/dist"
npm audit
fi
- name: Verify site ownership artifact
shell: bash
run: |
node <<'NODE'
const fs = require('node:fs');
const { createHash } = require('node:crypto');
const file = 'google4524eb8336ad041b.html';
const source = fs.readFileSync(`tooling/docs/public/${file}`);
const artifact = fs.readFileSync(`release/website/dist/${file}`);
if (!source.equals(artifact)) {
throw new Error('Built site verification file differs from its source.');
}
const sha256 = createHash('sha256').update(artifact).digest('hex');
fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, `\nVerification file SHA-256: ${sha256}\n`);
NODE
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: ./release/website/dist
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
- name: Summarize stable docs deployment
shell: bash
run: |
{
echo "## Stable documentation deployed"
echo
echo "Release tag: \`${{ inputs.release_tag }}\`"
echo
echo "Pages URL: ${{ steps.deployment.outputs.page_url }}"
} >> "${GITHUB_STEP_SUMMARY}"