1
1
version : 2.1
2
2
3
- parameters :
4
- cleanup_preview_branch :
5
- type : string
6
- default : " "
7
-
8
3
orbs :
9
4
aws-cli :
circleci/[email protected]
10
5
6
+
11
7
12
8
executors :
13
9
node_executor :
14
10
docker :
15
11
- image : cimg/node:22.15.1
16
12
working_directory : ~/project
17
13
18
- python_executor :
14
+ go_executor :
19
15
docker :
20
- - image : cimg/python:3.12.11
16
+ - image : cimg/go:1.24
21
17
working_directory : ~/project
22
18
23
19
ruby_executor :
@@ -33,25 +29,6 @@ commands:
33
29
aws_secret_access_key : ${AWS_SECRET_ACCESS_KEY}
34
30
region : ${AWS_REGION}
35
31
36
- sanitize-branch :
37
- steps :
38
- - run :
39
- name : Sanitize Branch Name
40
- command : |
41
- if [ -n "<< pipeline.parameters.cleanup_preview_branch >>" ]; then
42
- BRANCH_TO_USE="<< pipeline.parameters.cleanup_preview_branch >>"
43
- echo "[INFO] Using provided branch param: ${BRANCH_TO_USE}"
44
- else
45
- BRANCH_TO_USE="${CIRCLE_BRANCH}"
46
- echo "[INFO] Using current branch: ${BRANCH_TO_USE}"
47
- fi
48
-
49
- # Replace forward-slashes and spaces with double underscore
50
- SANITIZED_BRANCH=$(echo "${BRANCH_TO_USE}" | tr '/ ' '__')
51
- echo "[INFO] Sanitized branch: ${SANITIZED_BRANCH}"
52
- echo "export SANITIZED_BRANCH=${SANITIZED_BRANCH}" >> $BASH_ENV
53
- source $BASH_ENV
54
-
55
32
notify_error :
56
33
parameters :
57
34
message :
93
70
echo "[INFO] Starting Antora build..."
94
71
npm run build:docs
95
72
echo "[INFO] Antora build completed."
96
- - run :
97
- name : Create ZIP Archive of Build
98
- command : |
99
- set -e
100
- echo "[INFO] Creating zip archive of build directory..."
101
- zip -r build.zip build/
102
73
- store_artifacts :
103
- path : build.zip
104
- destination : preview-site.zip
105
- - persist_to_workspace :
106
- root : .
107
- paths :
108
- - build
109
- - build.zip
110
- - scripts
74
+ path : build
111
75
- persist_to_workspace :
112
76
root : .
113
77
paths :
@@ -142,148 +106,37 @@ jobs:
142
106
- notify_error :
143
107
message : " Validation job failed for branch ${CIRCLE_BRANCH}"
144
108
145
- deploy-preview :
146
- executor : node_executor
147
- steps :
148
- - attach_workspace :
149
- at : .
150
- - sanitize-branch
151
- - run :
152
- name : Install GitHub CLI
153
- command : |
154
- set -e
155
- echo "[INFO] Installing GitHub CLI..."
156
- curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
157
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
158
- sudo apt update
159
- sudo apt install gh
160
- - run :
161
- name : Upload Preview ZIP to GitHub Release and Comment
162
- command : |
163
- set -e
164
-
165
- if [[ -n "${CIRCLE_PULL_REQUEST}" ]]; then
166
- PR_NUMBER=$(echo "$CIRCLE_PULL_REQUEST" | sed 's|.*/pull/||')
167
- REPO_PATH="circleci/circleci-docs-static"
168
- TAG="pr-${SANITIZED_BRANCH}"
169
-
170
- echo "[INFO] Creating release for PR #${PR_NUMBER} - branch ${SANITIZED_BRANCH} in ${REPO_PATH}"
171
-
172
- # Check if release already exists (if re-run)
173
- if gh release view "${TAG}" -R "${REPO_PATH}" > /dev/null 2>&1; then
174
- echo "[INFO] Release already exists. Replacing..."
175
- gh release delete "${TAG}" -R "${REPO_PATH}" --yes
176
- fi
177
-
178
- # Create new release and upload ZIP
179
- gh release create "${TAG}" build.zip \
180
- --repo "${REPO_PATH}" \
181
- --title "Preview for PR #${PR_NUMBER}" \
182
- --notes "ZIP artifact for documentation preview." \
183
- --prerelease
184
-
185
- DOWNLOAD_URL="https://github.com/${REPO_PATH}/releases/tag/${TAG}/build.zip"
186
-
187
- # Comment on the PR with release link
188
- gh pr comment "${PR_NUMBER}" -R "${REPO_PATH}" -b "## Preview Documentation
189
-
190
- 📦 ZIP preview available here: [Preview Build Assets](${DOWNLOAD_URL})
191
-
192
- Build: ${CIRCLE_BUILD_NUM} | Commit: ${CIRCLE_SHA1}"
193
- else
194
- echo "[INFO] Not a PR build, skipping preview release."
195
- fi
196
- - notify_error :
197
- message : " Deploy preview job failed for branch ${CIRCLE_BRANCH}"
198
-
199
109
deploy-production :
200
- executor : python_executor
110
+ executor : go_executor
201
111
parameters :
202
112
bucket_name :
203
113
description : The name of the s3 bucket where static assets are stored.
204
114
type : string
205
- build_dir :
206
- default : " build"
207
- description : The path to the docs build directory
208
- type : string
209
115
steps :
116
+ - checkout
210
117
- attach_workspace :
211
118
at : .
212
119
- aws-setup
213
- - run :
214
- name : Deploy Production Site to S3
215
- command : |
216
- AWS_S3_BUCKET=<< parameters.bucket_name >>
217
- BUILD_DIRECTORY=<< parameters.build_dir >>
218
-
219
- set -e
220
- echo "[INFO] Deploying production site..."
221
- aws s3 sync "$BUILD_DIRECTORY" "s3://$AWS_S3_BUCKET/"
222
- - run :
223
- name : install pyyaml requests
224
- command : |
225
- set -e
226
- echo "[INFO] Installing pyyaml requests..."
227
- pip install pyyaml requests
228
- - run :
229
- name : Deploy Redirects to S3
230
- command : |
231
- AWS_S3_BUCKET=<< parameters.bucket_name >>
232
-
233
- set -e
234
- echo "[INFO] Deploying redirects..."
235
- #REMEMBER TO UPDATE THE START/END PARAMETER IN THE VALIDATE JOB TO MATCH
236
- python scripts/create-redirects.py $AWS_S3_BUCKET
237
- - run :
238
- name : Validate Redirects
239
- command : |
240
- set -e
241
- echo "[INFO] Validating redirects..."
242
- python scripts/validate-redirects.py https://circleci.com/docs-preview
120
+ - go/with-cache :
121
+ steps :
122
+ - go/mod-download
123
+ - run :
124
+ name : Deploy Production Site to S3
125
+ command : |
126
+ echo "[INFO] Deploying production site..."
127
+ dir=$(mktemp -d)
128
+ mv build "${dir}/docs"
129
+ aws s3 sync "${dir}" "s3://<< parameters.bucket_name >>/" \
130
+ --delete
131
+ - run :
132
+ name : Deploy Redirects to S3
133
+ command : go run ./cmd/create-redirects "<< parameters.bucket_name >>"
134
+ - run :
135
+ name : Validate Redirects
136
+ command : go run ./cmd/validate-redirects https://circleci.com
243
137
- notify_error :
244
138
message : " Production deployment job failed for branch ${CIRCLE_BRANCH}"
245
139
246
- cleanup-preview :
247
- executor : node_executor
248
- steps :
249
- - sanitize-branch
250
- - run :
251
- name : Install GitHub CLI
252
- command : |
253
- set -e
254
- echo "[INFO] Installing GitHub CLI..."
255
- curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
256
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
257
- sudo apt update
258
- sudo apt install gh
259
- - run :
260
- name : Delete GitHub Release and Tag
261
- command : |
262
- set -e
263
- BRANCH="<< pipeline.parameters.cleanup_preview_branch >>"
264
- REPO_PATH="circleci/circleci-docs-static"
265
-
266
- # Extract TAG
267
- TAG="pr-${SANITIZED_BRANCH}"
268
-
269
- echo "[INFO] Cleaning up GitHub Release for ${TAG} in ${REPO_PATH}"
270
-
271
- # Delete the release if it exists
272
- if gh release view "${TAG}" -R "${REPO_PATH}" > /dev/null 2>&1; then
273
- gh release delete "${TAG}" -R "${REPO_PATH}" --yes
274
- echo "[INFO] Release '${TAG}' deleted."
275
- else
276
- echo "[WARN] Release '${TAG}' not found."
277
- fi
278
-
279
- # Delete the tag if it exists
280
- if gh api -X GET "repos/${REPO_PATH}/git/refs/tags/${TAG}" > /dev/null 2>&1; then
281
- gh tag delete "${TAG}" -R "${REPO_PATH}" --yes
282
- echo "[INFO] Tag '${TAG}' deleted."
283
- else
284
- echo "[WARN] Tag '${TAG}' not found."
285
- fi
286
-
287
140
workflows :
288
141
lint :
289
142
unless :
@@ -293,25 +146,11 @@ workflows:
293
146
reference_branch : main
294
147
base_dir : docs
295
148
build_validate_and_deploy :
296
- when :
297
- equal : ["", << pipeline.parameters.cleanup_preview_branch >>]
298
149
jobs :
299
150
- build :
300
151
context : circleci-docs-static
301
152
- validate :
302
153
requires : [build]
303
- - deploy-preview :
304
- requires : [validate]
305
- filters :
306
- branches :
307
- ignore : main
308
- context :
309
- [
310
- circleci-docs-static,
311
- docs-platform-assets,
312
- web-ui-npm,
313
- web-ui-datadog,
314
- ]
315
154
- deploy-production :
316
155
requires : [validate]
317
156
filters :
@@ -325,9 +164,3 @@ workflows:
325
164
web-ui-datadog,
326
165
]
327
166
bucket_name : " circleci-docs-platform-assets"
328
- build_dir : " build"
329
- cleanup_preview :
330
- when : pipeline.parameters.cleanup_preview_branch != ""
331
- jobs :
332
- - cleanup-preview :
333
- context : circleci-docs-static
0 commit comments