diff --git a/.github/actions/deploy/action.yaml b/.github/actions/deploy/action.yaml index 217391de..f90e8cd3 100644 --- a/.github/actions/deploy/action.yaml +++ b/.github/actions/deploy/action.yaml @@ -10,6 +10,9 @@ inputs: aws_s3_sync_args: description: additional arguments for s3 sync command required: true + aws_s3_cache: + description: cache value for s3 sync command + required: true cloudfront_distribution_id: description: the CloudFront cache id to invalidate required: true @@ -26,7 +29,7 @@ runs: aws-region: eu-west-1 - name: Sync files to the bucket run: | - aws s3 sync dist ${{ inputs.aws_deploy_path }} --delete --cache-control max-age=3600 ${{ inputs.aws_s3_sync_args }} --no-progress + aws s3 sync dist ${{ inputs.aws_deploy_path }} --delete --cache-control ${{ inputs.aws_s3_cache }} ${{ inputs.aws_s3_sync_args }} --no-progress shell: bash - name: Invalidate CloudFront cache run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ inputs.cloudfront_distribution_id }} --paths ${{ inputs.cloudfront_invalidation_paths }} diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index afcf2e67..e6db1bd8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,12 +17,13 @@ jobs: node-version: '18' - name: Install deps, build and test project uses: ./.github/actions/install -# - name: Deploy to staging -# if: ${{ github.ref_name == 'main' }} -# uses: ./.github/actions/deploy -# with: -# aws_role: ${{ secrets.AWS_ROLE_STAGING_ACCOUNT }} -# aws_deploy_path: ${{ secrets.AWS_STAGING_BUCKET }} -# aws_s3_sync_args: '--include \"*\" --exclude \"*/*\"' -# cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_STAGING }} -# cloudfront_invalidation_paths: '/*' \ No newline at end of file + - name: Deploy to staging + if: ${{ github.ref_name == 'main' }} + uses: ./.github/actions/deploy + with: + aws_role: ${{ secrets.AWS_ROLE_STAGING_ACCOUNT }} + aws_deploy_path: ${{ secrets.AWS_STAGING_BUCKET }} + aws_s3_sync_args: --include '*' --exclude '*/*' + aws_s3_cache: no-store + cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_STAGING }} + cloudfront_invalidation_paths: '/*' \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3c85bef2..80783149 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -25,7 +25,8 @@ jobs: with: aws_role: ${{ secrets.AWS_ROLE_TEST_ACCOUNT }} aws_deploy_path: ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} - aws_s3_sync_args: '--include \"*\" --exclude \"*/*\"' + aws_s3_sync_args: --include '*' --exclude '*/*' + aws_s3_cache: no-store cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_TEST }} cloudfront_invalidation_paths: '/preview/${{ github.event.number }}/*' - name: Adding comment to PR with preview link and validation results