Skip to content

Commit 2ea6268

Browse files
committed
Deploy documentation previews to github actions
An attempt to upload our documentation to Netlify, to make it easier to review. Part of #181
1 parent ded083c commit 2ea6268

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

.github/workflows/ci.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,17 @@ jobs:
135135
yarn install
136136
yarn build && yarn doc
137137
138+
# Upload the docs as a build artifiact, so they can be used in the
139+
# deployment step below, or a subsequent workflow which uploads to netlify.
138140
- name: Upload artifact
139-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
140141
uses: actions/upload-pages-artifact@v3
141142
with:
143+
name: docs
142144
path: './docs/'
143145

144146
- name: Deploy to GitHub Pages
145147
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
146148
id: deployment
147149
uses: actions/deploy-pages@v4
150+
with:
151+
artifact_name: docs

.github/workflows/netlify.yaml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# GHA workflow which publishes previews of the docs to Netlify.
2+
#
3+
# We keep this in a separate workflow to the main build, because it
4+
# requires access to the Netlify secret. By having it run on `workflow_run`, we
5+
# will only use the workflow definition file on the default branch, so we can
6+
# ensure that the secret can't be exfiltrated.
7+
8+
name: Deploy documentation PR preview
9+
10+
on:
11+
workflow_run:
12+
workflows: ["CI"]
13+
types:
14+
- completed
15+
16+
permissions: {}
17+
18+
jobs:
19+
netlify:
20+
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request'
21+
runs-on: ubuntu-24.04
22+
permissions:
23+
actions: read
24+
deployments: write
25+
26+
# Tell github to share the right secrets
27+
environment: PR Documentation Preview
28+
29+
steps:
30+
- name: 📥 Download artifact
31+
uses: actions/download-artifact@v4
32+
with:
33+
github-token: ${{ secrets.GITHUB_TOKEN }}
34+
run-id: ${{ github.event.workflow_run.id }}
35+
name: docs
36+
path: docs
37+
38+
- name: 📤 Deploy to Netlify
39+
uses: matrix-org/netlify-pr-preview@v3
40+
with:
41+
path: docs
42+
43+
# Pass the details of the workflow run that just completed into the action.
44+
# This allows it to figure out the PR number.
45+
owner: ${{ github.event.workflow_run.head_repository.owner.login }}
46+
branch: ${{ github.event.workflow_run.head_branch }}
47+
revision: ${{ github.event.workflow_run.head_sha }}
48+
49+
token: ${{ secrets.NETLIFY_AUTH_TOKEN }}
50+
site_id: dcaf4b8b-3a2d-4498-ad8f-ca73f36a43e0
51+
52+
desc: Documentation preview
53+
deployment_env: PR Documentation Preview
54+

0 commit comments

Comments
 (0)