Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brettgullan/fc714c38a9903e80eafef55979891ad7 to your computer and use it in GitHub Desktop.
Save brettgullan/fc714c38a9903e80eafef55979891ad7 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 /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment