-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
480ef95
commit 567a228
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: docs | ||
|
||
on: | ||
push: | ||
branches: [ 'release-docs' ] | ||
|
||
pull_request: | ||
paths: | ||
- 'docs/**' | ||
|
||
concurrency: | ||
group: docs-${{ github.workflow }}-${{ github.ref_type }}-${{ github.event.pull_request.number || github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash -euo pipefail {0} | ||
|
||
env: | ||
GITHUB_REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }} | ||
|
||
jobs: | ||
|
||
docs: | ||
name: "docs" | ||
runs-on: "ubuntu-24.04" | ||
environment: | ||
name: ${{ github.ref }} | ||
|
||
steps: | ||
- uses: "actions/checkout@v4" | ||
with: | ||
fetch-depth: 1 | ||
submodules: true | ||
|
||
- uses: "actions/setup-node@v4" | ||
with: | ||
node-version: "22" | ||
|
||
- name: "Install deps" | ||
run: | | ||
sudo apt-get install rename --yes -qq >/dev/null | ||
cd docs/ | ||
npm install -g bun | ||
bun install | ||
- name: "Build docs" | ||
run: | | ||
cd docs/ | ||
bun prod:build | ||
- name: "Deploy docs" | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} | ||
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | ||
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
if: ${{ github.ref == 'refs/heads/release-docs' }} | ||
run: | | ||
cd docs/ | ||
./deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
shopt -s globstar | ||
trap "exit" INT | ||
|
||
: "${AWS_S3_BUCKET:?The environment variable is required}" | ||
: "${AWS_CLOUDFRONT_DISTRIBUTION_ID:?The environment variable is required}" | ||
|
||
export AWS_MAX_ATTEMPTS=10 | ||
|
||
pushd "build" >/dev/null | ||
{ | ||
# Upload non-HTML files | ||
aws s3 sync \ | ||
--delete \ | ||
--only-show-errors \ | ||
--cache-control "max-age=2592000, public" \ | ||
--metadata-directive REPLACE \ | ||
--exclude "*.html" \ | ||
. "s3://${AWS_S3_BUCKET}/" | ||
|
||
# Remove non-HTML files | ||
find . -type f \( ! -iname "*.html" \) -exec rm {} \+ | ||
|
||
# Remove .html extension | ||
rename --filename 's/\.html//' **/*.html || true | ||
|
||
# Upload extensionless HTML files | ||
aws s3 sync \ | ||
--delete \ | ||
--only-show-errors \ | ||
--content-type "text/html" \ | ||
--cache-control "max-age=0, must-revalidate" \ | ||
--metadata-directive REPLACE \ | ||
--exclude "*.*" \ | ||
. "s3://${AWS_S3_BUCKET}/" | ||
|
||
# Update Cloudfront cache | ||
aws cloudfront create-invalidation \ | ||
--no-paginate \ | ||
--distribution-id "${AWS_CLOUDFRONT_DISTRIBUTION_ID}" \ | ||
--paths "/*" \ | ||
>/dev/null | ||
} | ||
popd >/dev/null |