Skip to content

Instantly share code, notes, and snippets.

@Marcel-G
Last active September 7, 2023 08:49
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Marcel-G/a73486322161c84757096a2e3855a3c9 to your computer and use it in GitHub Desktop.
Save Marcel-G/a73486322161c84757096a2e3855a3c9 to your computer and use it in GitHub Desktop.
pipelines:
branches:
master:
- step:
name: Build static html files
image: node:8.9.4-slim
caches:
- node
script:
- npm install
- rm -rf .next out # Remove built directories from previous builds (prevent EEXIST error)
- npm run export
- cp public/* out
artifacts:
- out/**
- step:
name: Deploy to S3
image: atlassian/pipelines-awscli
# Sync to s3, update cache-control header for /static & /_next. Clear cloudfront cache.
# --metadata-directive REPLACE https://github.com/aws/aws-cli/issues/652
script:
- aws s3 sync out/ s3://$ROOT_DOMAIN_NAME --acl public-read --delete
- aws s3 cp s3://$ROOT_DOMAIN_NAME/static/ s3://$ROOT_DOMAIN_NAME/static/ --metadata-directive REPLACE --cache-control 'max-age=31104000' --recursive
- aws s3 cp s3://$ROOT_DOMAIN_NAME/_next/ s3://$ROOT_DOMAIN_NAME/_next/ --metadata-directive REPLACE --cache-control 'max-age=31104000' --recursive
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths /
@VivienGiraud
Copy link

Thank you Marcel !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment