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
- - image : cimg/node:22.15.1
11
+ - image : cimg/node:22.18.0
12
+ working_directory : ~/project
13
+
14
+ go_executor :
15
+ docker :
16
+ - image : cimg/go:1.25
16
17
working_directory : ~/project
17
18
18
19
ruby_executor :
19
20
docker :
20
- - image : cimg/ruby:3.4
21
+ - image : cimg/ruby:3.4.5
21
22
working_directory : ~/project
22
23
23
24
commands :
@@ -28,25 +29,6 @@ commands:
28
29
aws_secret_access_key : ${AWS_SECRET_ACCESS_KEY}
29
30
region : ${AWS_REGION}
30
31
31
- sanitize-branch :
32
- steps :
33
- - run :
34
- name : Sanitize Branch Name
35
- command : |
36
- if [ -n "<< pipeline.parameters.cleanup_preview_branch >>" ]; then
37
- BRANCH_TO_USE="<< pipeline.parameters.cleanup_preview_branch >>"
38
- echo "[INFO] Using provided branch param: ${BRANCH_TO_USE}"
39
- else
40
- BRANCH_TO_USE="${CIRCLE_BRANCH}"
41
- echo "[INFO] Using current branch: ${BRANCH_TO_USE}"
42
- fi
43
-
44
- # Replace forward-slashes and spaces with double underscore
45
- SANITIZED_BRANCH=$(echo "${BRANCH_TO_USE}" | tr '/ ' '__')
46
- echo "[INFO] Sanitized branch: ${SANITIZED_BRANCH}"
47
- echo "export SANITIZED_BRANCH=${SANITIZED_BRANCH}" >> $BASH_ENV
48
- source $BASH_ENV
49
-
50
32
notify_error :
51
33
parameters :
52
34
message :
@@ -77,31 +59,16 @@ jobs:
77
59
- " SHA256:Plac654CPBty6yA26H7QMKCqM0yD1XWds7UwNqOYzJU"
78
60
- run :
79
61
name : Install Node Dependencies
80
- command : |
81
- set -e
82
- echo "[INFO] Installing Node dependencies..."
83
- npm ci
62
+ command : npm ci
84
63
- run :
85
64
name : Build the Documentation Site with Antora
86
65
command : |
87
66
set -e
88
67
echo "[INFO] Starting Antora build..."
89
68
npm run build:docs
90
69
echo "[INFO] Antora build completed."
91
- - run :
92
- name : Create ZIP Archive of Build
93
- command : |
94
- set -e
95
- echo "[INFO] Creating zip archive of build directory..."
96
- zip -r build.zip build/
97
70
- store_artifacts :
98
- path : build.zip
99
- destination : preview-site.zip
100
- - persist_to_workspace :
101
- root : .
102
- paths :
103
- - build
104
- - build.zip
71
+ path : build
105
72
- persist_to_workspace :
106
73
root : .
107
74
paths :
@@ -110,190 +77,64 @@ jobs:
110
77
message : " Build job failed for branch ${CIRCLE_BRANCH}"
111
78
112
79
validate :
113
- executor : ruby_executor
80
+ executor : go_executor
114
81
steps :
82
+ - checkout
115
83
- attach_workspace :
116
84
at : .
117
- - run :
118
- name : Install HTML Proofer
119
- command : |
120
- set -e
121
- echo "[INFO] Installing HTML Proofer gem..."
122
- sudo gem install html-proofer
123
- - run :
124
- name : Run HTML Proofer Validation
125
- command : |
126
- set -e
127
- echo "[INFO] Validating built site with HTML Proofer..."
128
- htmlproofer ./build --checks html --ignore-urls "/#.*/" --ignore-empty-alt
85
+ - go/with-cache :
86
+ golangci-lint : true
87
+ steps :
88
+ - run : task mod-download
89
+ - run : task ci:diff
90
+ - run : task ci:lint
91
+ - run : task validate-html
129
92
- notify_error :
130
93
message : " Validation job failed for branch ${CIRCLE_BRANCH}"
131
94
132
- deploy-preview :
133
- executor : node_executor
134
- steps :
135
- - attach_workspace :
136
- at : .
137
- - sanitize-branch
138
- - run :
139
- name : Install GitHub CLI
140
- command : |
141
- set -e
142
- echo "[INFO] Installing GitHub CLI..."
143
- curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
144
- 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
145
- sudo apt update
146
- sudo apt install gh
147
- - run :
148
- name : Upload Preview ZIP to GitHub Release and Comment
149
- command : |
150
- set -e
151
-
152
- if [[ -n "${CIRCLE_PULL_REQUEST}" ]]; then
153
- PR_NUMBER=$(echo "$CIRCLE_PULL_REQUEST" | sed 's|.*/pull/||')
154
- REPO_PATH="circleci/circleci-docs-static"
155
- TAG="pr-${SANITIZED_BRANCH}"
156
-
157
- echo "[INFO] Creating release for PR #${PR_NUMBER} - branch ${SANITIZED_BRANCH} in ${REPO_PATH}"
158
-
159
- # Check if release already exists (if re-run)
160
- if gh release view "${TAG}" -R "${REPO_PATH}" > /dev/null 2>&1; then
161
- echo "[INFO] Release already exists. Replacing..."
162
- gh release delete "${TAG}" -R "${REPO_PATH}" --yes
163
- fi
164
-
165
- # Create new release and upload ZIP
166
- gh release create "${TAG}" build.zip \
167
- --repo "${REPO_PATH}" \
168
- --title "Preview for PR #${PR_NUMBER}" \
169
- --notes "ZIP artifact for documentation preview." \
170
- --prerelease
171
-
172
- DOWNLOAD_URL="https://github.com/${REPO_PATH}/releases/tag/${TAG}/build.zip"
173
-
174
- # Comment on the PR with release link
175
- gh pr comment "${PR_NUMBER}" -R "${REPO_PATH}" -b "## Preview Documentation
176
-
177
- 📦 ZIP preview available here: [Preview Build Assets](${DOWNLOAD_URL})
178
-
179
- Build: ${CIRCLE_BUILD_NUM} | Commit: ${CIRCLE_SHA1}"
180
- else
181
- echo "[INFO] Not a PR build, skipping preview release."
182
- fi
183
- - notify_error :
184
- message : " Deploy preview job failed for branch ${CIRCLE_BRANCH}"
185
-
186
95
deploy-production :
187
- executor : node_executor
188
- parameters :
189
- bucket_name :
190
- description : The name of the s3 bucket where static assets are stored.
191
- type : string
192
- build_dir :
193
- default : " build"
194
- description : The path to the docs build directory
195
- type : string
96
+ executor : go_executor
196
97
steps :
98
+ - checkout
197
99
- attach_workspace :
198
100
at : .
199
101
- aws-setup
200
- - run :
201
- name : Deploy Production Site to S3
202
- command : |
203
- AWS_S3_BUCKET=<< parameters.bucket_name >>
204
- BUILD_DIRECTORY=<< parameters.build_dir >>
205
-
206
- set -e
207
- echo "[INFO] Deploying production site..."
208
- aws s3 sync "$BUILD_DIRECTORY" "s3://$AWS_S3_BUCKET/"
102
+ - go/with-cache :
103
+ steps :
104
+ - run : task mod-download
105
+ - run : task deploy
106
+ - run : task deploy-redirects
107
+ - run : task validate-redirects
209
108
- notify_error :
210
109
message : " Production deployment job failed for branch ${CIRCLE_BRANCH}"
211
110
212
- cleanup-preview :
213
- executor : node_executor
214
- steps :
215
- - sanitize-branch
216
- - run :
217
- name : Install GitHub CLI
218
- command : |
219
- set -e
220
- echo "[INFO] Installing GitHub CLI..."
221
- curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
222
- 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
223
- sudo apt update
224
- sudo apt install gh
225
- - run :
226
- name : Delete GitHub Release and Tag
227
- command : |
228
- set -e
229
- BRANCH="<< pipeline.parameters.cleanup_preview_branch >>"
230
- REPO_PATH="circleci/circleci-docs-static"
231
-
232
- # Extract TAG
233
- TAG="pr-${SANITIZED_BRANCH}"
234
-
235
- echo "[INFO] Cleaning up GitHub Release for ${TAG} in ${REPO_PATH}"
236
-
237
- # Delete the release if it exists
238
- if gh release view "${TAG}" -R "${REPO_PATH}" > /dev/null 2>&1; then
239
- gh release delete "${TAG}" -R "${REPO_PATH}" --yes
240
- echo "[INFO] Release '${TAG}' deleted."
241
- else
242
- echo "[WARN] Release '${TAG}' not found."
243
- fi
244
-
245
- # Delete the tag if it exists
246
- if gh api -X GET "repos/${REPO_PATH}/git/refs/tags/${TAG}" > /dev/null 2>&1; then
247
- gh tag delete "${TAG}" -R "${REPO_PATH}" --yes
248
- echo "[INFO] Tag '${TAG}' deleted."
249
- else
250
- echo "[WARN] Tag '${TAG}' not found."
251
- fi
252
-
253
111
workflows :
254
- lint :
255
- unless :
256
- equal : [main, << pipeline.git.branch >>]
112
+ main :
257
113
jobs :
258
114
- vale/lint :
259
115
reference_branch : main
260
116
base_dir : docs
261
- build_validate_and_deploy :
262
- when :
263
- equal : ["", << pipeline.parameters.cleanup_preview_branch >>]
264
- jobs :
117
+ filters : pipeline.git.branch != "main"
118
+
265
119
- build :
266
- context : circleci-docs-static
267
- - validate :
268
- requires : [build]
269
- - deploy-preview :
270
- requires : [validate]
271
- filters :
272
- branches :
273
- ignore : main
120
+ filters : pipeline.git.branch == "main"
121
+ name : build-main
274
122
context :
275
- [
276
- circleci-docs-static,
277
- docs-platform-assets,
278
- web-ui-npm,
279
- web-ui-datadog,
280
- ]
123
+ - circleci-docs-static
124
+ - build :
125
+ filters : pipeline.git.branch != "main"
126
+
127
+ - validate :
128
+ requires :
129
+ - build-main
130
+ - build
131
+
281
132
- deploy-production :
282
- requires : [validate]
283
- filters :
284
- branches :
285
- only : main
133
+ requires :
134
+ - validate
135
+ filters : pipeline.git.branch == "main"
286
136
context :
287
- [
288
- circleci-docs-static,
289
- docs-platform-assets,
290
- web-ui-npm,
291
- web-ui-datadog,
292
- ]
293
- bucket_name : " circleci-docs-platform-assets/docs-preview"
294
- build_dir : " build"
295
- cleanup_preview :
296
- when : pipeline.parameters.cleanup_preview_branch != ""
297
- jobs :
298
- - cleanup-preview :
299
- context : circleci-docs-static
137
+ - circleci-docs-static
138
+ - docs-platform-assets
139
+ - web-ui-npm
140
+ - web-ui-datadog
0 commit comments