Skip to content

Commit 1becdf9

Browse files
chore: setup infra for docs
1 parent 480ef95 commit 1becdf9

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

Diff for: .github/workflows/docs.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: docs
2+
3+
on:
4+
push:
5+
branches: [ 'release-docs' ]
6+
7+
pull_request:
8+
paths:
9+
- 'docs/**'
10+
11+
concurrency:
12+
group: cli-${{ github.workflow }}-${{ github.ref_type }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
defaults:
16+
run:
17+
shell: bash -euo pipefail {0}
18+
19+
env:
20+
GITHUB_REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }}
21+
22+
jobs:
23+
24+
docs:
25+
name: "docs"
26+
runs-on: "ubuntu-24.04"
27+
environment:
28+
name: ${{ github.ref }}
29+
30+
steps:
31+
- uses: "actions/checkout@v4"
32+
with:
33+
fetch-depth: 1
34+
submodules: true
35+
36+
- uses: "actions/setup-node@v4"
37+
with:
38+
node-version: "22"
39+
40+
- name: "install dependencies"
41+
run: |
42+
npm install -g bun
43+
bun install
44+
45+
- name: "build docs"
46+
run: |
47+
bun prod:build
48+
49+
- name: "deploy docs"
50+
if: ${{ endsWith(github.ref, '/release-docs') }}
51+
run: |
52+
./docs/deploy

Diff for: docs/deploy

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
shopt -s globstar
4+
trap "exit" INT
5+
6+
: "${AWS_S3_BUCKET:?The environment variable is required}"
7+
: "${AWS_CLOUDFRONT_DISTRIBUTION_ID:?The environment variable is required}"
8+
9+
export AWS_MAX_ATTEMPTS=10
10+
11+
pushd "docs/build" >/dev/null
12+
{
13+
# Upload non-HTML files
14+
aws s3 sync \
15+
--delete \
16+
--only-show-errors \
17+
--cache-control "max-age=2592000, public" \
18+
--metadata-directive REPLACE \
19+
--exclude "*.html" \
20+
. "s3://${AWS_S3_BUCKET}/"
21+
22+
# Remove .html extension from HTML files and move them to a separate directory to handle them separately
23+
mkdir -p temporary_htmls
24+
find . -type f -name "*.html" -exec bash -c 'mv "$0" "temporary_htmls/${0%.html}"' {} \;
25+
26+
# Upload extensionless HTML files
27+
aws s3 sync \
28+
--delete \
29+
--only-show-errors \
30+
--content-type "text/html" \
31+
--cache-control "max-age=0, must-revalidate" \
32+
--metadata-directive REPLACE \
33+
temporary_htmls/ "s3://${AWS_S3_BUCKET}/"
34+
35+
# Update Cloudfront cache
36+
aws cloudfront create-invalidation \
37+
--no-paginate \
38+
--distribution-id "${AWS_CLOUDFRONT_DISTRIBUTION_ID}" \
39+
--paths "/*" \
40+
>/dev/null
41+
}
42+
popd >/dev/null

0 commit comments

Comments
 (0)