Skip to content

Commit

Permalink
ci: fix deployment in staging bucket (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauramargar authored Oct 26, 2023
1 parent ccb2306 commit b783771
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .github/actions/deploy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '/*'
- 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: '/*'
3 changes: 2 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b783771

Please sign in to comment.