Forked from Marcel-G/aws-static-nextjs-bitbucket-pipeline.yml
          
        
    
          Created
          June 29, 2021 06:21 
        
      - 
      
- 
        Save brettgullan/fc714c38a9903e80eafef55979891ad7 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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
    
  
  
    
  | 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