Repository navigation
126 lines (107 loc) · 4.74 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
126 lines (107 loc) · 4.74 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
name: Deploy Docs
# The docs site is versioned independently of the shipped artifacts: `docs` sits
# outside the `fixed` group in .changeset/config.json, so it moves only when a
# changeset names it. Its deploy has to follow the same rule, otherwise a cycle
# that only touched the docs site produces no release, no tag, and no deploy,
# and the work sits on main unpublished.
on:
# A docs version was just cut. `apps/docs/package.json` is rewritten by
# `changeset version` when a `docs` changeset lands, so merging the version PR
# is the signal. The guard below rejects any other reason that file changed.
push:
branches: [main]
paths: ["apps/docs/package.json"]
# A product release carries a new changelog entry under
# apps/docs/content/changelog/, which the site renders and feeds to its
# version switcher. Those have to reach the site even when `docs` itself did
# not move.
#
# Stable releases only; the guard below skips a prerelease. A release
# candidate is cut from `next`, and deploying from its tag would publish
# `next`'s docs as the site, describing a version `latest` does not yet
# serve. The rc's own entry reaches the site when it ships as stable.
release:
types: [published]
# Escape hatch: republish the current main without inventing a commit.
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
# Never let two deploys race for the Pages environment. Not cancel-in-progress:
# a half-finished deploy would leave the site serving a partial build.
concurrency:
group: deploy-docs
cancel-in-progress: false
jobs:
# `paths` fires on any write to apps/docs/package.json, including a dependency
# bump. Only a changed version field means a docs release, so confirm it here
# rather than deploying on every edit to that file.
changed:
runs-on: ubuntu-latest
outputs:
deploy: ${{ steps.check.outputs.deploy }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 2
- name: Check whether the docs version moved
id: check
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" == "true" ]]; then
echo "${{ github.event.release.tag_name }} is a prerelease; the site follows the stable line, not deploying."
echo "deploy=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "${{ github.event_name }}" != "push" ]]; then
echo "Event is ${{ github.event_name }}, deploying without a version check."
echo "deploy=true" >> "$GITHUB_OUTPUT"
exit 0
fi
CURRENT=$(node -p "require('./apps/docs/package.json').version")
# A first commit or a squashed history leaves no parent to compare
# against. Deploy rather than silently skipping: a missed deploy is
# harder to notice than a redundant one.
if ! PREVIOUS=$(git show HEAD~1:apps/docs/package.json 2>/dev/null \
| node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version"); then
echo "No parent revision to compare against, deploying."
echo "deploy=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "$CURRENT" == "$PREVIOUS" ]]; then
echo "docs is still at $CURRENT, nothing was released. Skipping."
echo "deploy=false" >> "$GITHUB_OUTPUT"
else
echo "docs moved $PREVIOUS -> $CURRENT, deploying."
echo "deploy=true" >> "$GITHUB_OUTPUT"
fi
deploy:
needs: changed
if: needs.changed.outputs.deploy == 'true'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
- run: pnpm install --frozen-lockfile
# The API reference renders this at build time from apps/docs/public/.
- name: Copy OpenAPI spec into docs
run: cp apps/server/openapi.json apps/docs/public/openapi.json
- name: Build docs
run: pnpm build:docs
- name: Upload artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: apps/docs/out
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1