Repository navigation
192 lines (165 loc) · 5.63 KB
/
Copy pathmanual_release_docs.yaml
File metadata and controls
192 lines (165 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
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
name: Release docs
on:
# Runs when manually triggered from the GitHub UI.
workflow_dispatch:
inputs:
ref:
description: Commit SHA or ref to build the docs from. If empty, the triggering ref is used.
required: false
type: string
default: ""
# Runs when invoked by another workflow.
workflow_call:
inputs:
ref:
description: Commit SHA or ref to build the docs from. If empty, the triggering ref is used.
required: false
type: string
default: ""
skip_checks:
description: Skip the release branch and `Checks` gate for the built commit. The calling workflows run their own gate.
required: false
type: boolean
default: true
permissions:
contents: read
env:
NODE_VERSION: 24
PYTHON_VERSION: 3.14
jobs:
build_docs:
name: Build docs
environment:
name: docs
deployment: false
permissions:
contents: read
checks: read
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.sha.outputs.sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v7.0.1
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Record the built commit
id: sha
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
# A manual dispatch builds only a commit that is on a release branch and passed the `Checks` workflow (run by
# `on_master.yaml`). Calling workflows skip both steps through `skip_checks`.
- name: Check that the commit is on a release branch
if: ${{ !inputs.skip_checks }}
env:
GH_TOKEN: ${{ github.token }}
SHA: ${{ steps.sha.outputs.sha }}
run: |
branches=$(gh api --paginate "repos/$GITHUB_REPOSITORY/branches" --jq '.[].name' | grep -E '^(master|release-v.+)$')
for branch in $branches; do
status=$(gh api "repos/$GITHUB_REPOSITORY/compare/$branch...$SHA" --jq .status || true)
if [[ "$status" == "identical" || "$status" == "behind" ]]; then
exit 0
fi
done
echo "::error::$SHA is not on a release branch"
exit 1
- name: Wait for checks
if: ${{ !inputs.skip_checks }}
uses: apify/actions/wait-for-checks@v1.9.0
with:
ref: ${{ steps.sha.outputs.sha }}
check-regexp: ^Checks
- name: Set up Node
uses: actions/setup-node@v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}
check-latest: true
- name: Set up Python
uses: actions/setup-python@v7.1.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up uv package manager
uses: astral-sh/setup-uv@v10.4.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python dependencies
run: uv run poe install-dev
- name: Install pnpm and website dependencies
uses: apify/actions/pnpm-install@v1.9.0
with:
working-directory: website
- name: Update docs theme
run: uv run poe update-docs-theme
- name: Upload the updated package.json and lockfile
uses: actions/upload-artifact@v7.0.2
with:
name: docs-theme-update
path: |
website/package.json
website/pnpm-lock.yaml
retention-days: 1
- name: Build docs
run: uv run poe build-docs
env:
SEGMENT_TOKEN: ${{ secrets.SEGMENT_TOKEN }}
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v5.0.0
with:
path: ./website/build
# The service account token is only used in jobs that do not run the docs toolchain.
commit_docs_theme:
name: Commit docs theme update
needs: [build_docs]
permissions:
contents: read
runs-on: ubuntu-latest
environment:
name: github-pages
deployment: false
steps:
- name: Checkout repository
uses: actions/checkout@v7.0.1
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
persist-credentials: false
# Start from the commit the update was made on, so the pull below merges it with anything pushed since.
- name: Reset to the built commit
run: git reset --hard "$BUILT_SHA"
env:
BUILT_SHA: ${{ needs.build_docs.outputs.sha }}
- name: Download the updated package.json and lockfile
uses: actions/download-artifact@v8.0.2
with:
name: docs-theme-update
path: website
- name: Commit the updated package.json and lockfile
uses: apify/actions/signed-commit@v1.9.0
with:
message: "chore: Automatic docs theme update [skip ci]"
add: website/package.json website/pnpm-lock.yaml
pull: --rebase --autostash
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
deploy_docs:
name: Deploy docs
needs: [build_docs]
environment:
name: github-pages
permissions:
pages: write
id-token: write
runs-on: ubuntu-latest
steps:
- name: Set up GitHub Pages
uses: actions/configure-pages@v6.0.0
- name: Deploy artifact to GitHub Pages
uses: actions/deploy-pages@v5.0.1
- name: Invalidate CloudFront cache
run: |
gh workflow run invalidate-cloudfront.yml \
--repo apify/apify-docs-private \
--field deployment=apify-docs
echo "✅ CloudFront cache invalidation workflow triggered successfully"
env:
GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}