Skip to content

Commit 07885bc

Browse files
committed
ci(release): deploy website to S3/CloudFront on stable release
After the `release` job tags a new version, build `packages/website`, sync it to the marketing-site S3 bucket, and invalidate the CloudFront distribution. Gated on `!contains(github.ref_name, '-')` so alpha/pre-release tags don't publish unreleased docs ahead of a stable CLI release. Assumes a new OIDC role (defined in private infrastructure) plus two GitHub repository variables: - `vars.WEBSITE_BUCKET` - `vars.WEBSITE_DISTRIBUTION_ID` And the secret `secrets.WEBSITE_DEPLOY_ROLE_ARN`. Fingerprinted assets under `_astro/` get a 1-year immutable cache; everything else gets a 5-minute revalidating cache to keep HTML/markdown fresh. Closes #99.
1 parent af314cb commit 07885bc

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,61 @@ jobs:
153153
--region us-east-1 \
154154
--content-type 'text/x-shellscript; charset=utf-8' \
155155
--cache-control 'public, max-age=300'
156+
157+
deploy-website:
158+
name: Deploy website
159+
needs: release
160+
# Skip alpha releases so unreleased docs do not publish before stable CLI releases.
161+
if: ${{ !contains(github.ref_name, '-') }}
162+
runs-on: ubuntu-latest
163+
timeout-minutes: 15
164+
permissions:
165+
contents: read
166+
id-token: write
167+
packages: read
168+
steps:
169+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
170+
with:
171+
fetch-depth: 0
172+
persist-credentials: false
173+
174+
- uses: ./.github/actions/bootstrap
175+
176+
- name: Build website
177+
run: bun run --cwd packages/website build
178+
179+
- name: Configure AWS credentials for website deploy
180+
uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1
181+
with:
182+
role-to-assume: ${{ secrets.WEBSITE_DEPLOY_ROLE_ARN }}
183+
aws-region: us-east-1
184+
role-session-name: website-${{ github.run_id }}
185+
186+
- name: Sync website to S3
187+
shell: bash
188+
env:
189+
WEBSITE_BUCKET: ${{ vars.WEBSITE_BUCKET }}
190+
run: |
191+
set -euo pipefail
192+
: "${WEBSITE_BUCKET:?Set WEBSITE_BUCKET repository variable}"
193+
aws s3 sync packages/website/dist/ "s3://${WEBSITE_BUCKET}/" \
194+
--delete \
195+
--exclude "_astro/*" \
196+
--cache-control "public, max-age=300, must-revalidate" \
197+
--region us-east-1
198+
aws s3 sync packages/website/dist/_astro/ "s3://${WEBSITE_BUCKET}/_astro/" \
199+
--delete \
200+
--cache-control "public, max-age=31536000, immutable" \
201+
--region us-east-1
202+
203+
- name: Invalidate website CloudFront cache
204+
shell: bash
205+
env:
206+
WEBSITE_DISTRIBUTION_ID: ${{ vars.WEBSITE_DISTRIBUTION_ID }}
207+
run: |
208+
set -euo pipefail
209+
: "${WEBSITE_DISTRIBUTION_ID:?Set WEBSITE_DISTRIBUTION_ID repository variable}"
210+
aws cloudfront create-invalidation \
211+
--distribution-id "${WEBSITE_DISTRIBUTION_ID}" \
212+
--paths "/*" \
213+
--region us-east-1

0 commit comments

Comments
 (0)