Skip to content

Commit b895baf

Browse files
committed
Use correct GHA permissions for docs deploy
Separate out the deploy step here to scope the permissions to just that publish, not the entire install & test run. This also now checks that something is actually deployed, and uses a flag instead of a version match to manage the matrix.
1 parent 2d3b47c commit b895baf

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ jobs:
77

88
strategy:
99
matrix:
10-
node-version: [20.x, 22.x, v22.20.0, '*']
10+
include:
11+
- node-version: 20.x
12+
- node-version: 22.x
13+
- node-version: 'v22.20.0'
14+
deploys-docs: true
15+
- node-version: '*'
1116

1217
steps:
1318
- uses: actions/checkout@v4
@@ -29,9 +34,35 @@ jobs:
2934
# We log performance test results to Posthog to track trends:
3035
POSTHOG_PERF_API_KEY: ${{ secrets.POSTHOG_PERF_API_KEY }}
3136

32-
- name: Deploy docs
33-
if: github.ref == 'refs/heads/main' && matrix.node-version == 'v22.20.0'
34-
uses: JamesIves/github-pages-deploy-action@v4
37+
- name: Upload docs artifact
38+
uses: actions/upload-artifact@v4
39+
if: matrix.deploys-docs == true
40+
with:
41+
name: typedoc
42+
path: typedoc
43+
retention-days: 1
44+
45+
deploy-docs:
46+
name: Deploy docs
47+
needs: build
48+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
49+
runs-on: ubuntu-latest
50+
permissions:
51+
contents: write
52+
steps:
53+
- uses: actions/checkout@v4
54+
- uses: actions/download-artifact@v4
55+
with:
56+
name: typedoc
57+
path: typedoc
58+
- name: Check for generated docs
59+
run: |
60+
# Fails if directory doesn't exist or is empty
61+
if [ ! -d "typedoc" ] || [ -z "$(ls -A typedoc)" ]; then
62+
echo "Error: 'typedoc' directory is missing or empty."
63+
exit 1
64+
fi
65+
- uses: JamesIves/github-pages-deploy-action@v4
3566
with:
3667
single-commit: true
3768
branch: gh-pages

0 commit comments

Comments
 (0)