Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,30 @@ jobs:
AWS_DEFAULT_REGION: ${{ secrets.STAGING_AWS_REGION }}

- name: Deploy
run: aws s3 sync ./dist s3://${{ secrets.PRODUCTION_AWS_S3_BUCKET }}/tech-docs --delete
# Order matters: live pages must never reference an asset that has not
# been uploaded yet, or one that has already been deleted.
run: |
# Hashed filenames change with their content, so size is enough to skip existing files.
aws s3 sync ./dist/_astro "$S3_PREFIX/_astro" --size-only
aws s3 sync ./dist "$S3_PREFIX" --exclude "_astro/*" --delete

# CloudFront caches rewritten URIs (/x/index.html), which these wildcards also match.
# Read top-level folders from the build so new sections are never missed.
# _astro is skipped because its filenames change with their content.
mapfile -t DIR_PATHS < <(cd dist && find . -mindepth 1 -maxdepth 1 -type d ! -name _astro ! -name '.*' -printf '/tech-docs/%P*\n')
INVALIDATION_ID=$(aws cloudfront create-invalidation \
--distribution-id "$DISTRIBUTION_ID" \
--paths "/tech-docs" "/tech-docs/" "/tech-docs/index.html" \
"${DIR_PATHS[@]}" \
"/tech-docs/sitemap-*" "/tech-docs/favicon.png" \
--query Invalidation.Id --output text)
aws cloudfront wait invalidation-completed \
--distribution-id "$DISTRIBUTION_ID" --id "$INVALIDATION_ID"

aws s3 sync ./dist/_astro "$S3_PREFIX/_astro" --size-only --delete
env:
S3_PREFIX: s3://${{ secrets.PRODUCTION_AWS_S3_BUCKET }}/tech-docs
DISTRIBUTION_ID: ${{ secrets.PRODUCTION_AWS_CLOUDFRONT_DISTRIBUTION_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.PRODUCTION_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PRODUCTION_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.PRODUCTION_AWS_REGION }}
AWS_DEFAULT_REGION: ${{ secrets.PRODUCTION_AWS_REGION }}
Loading