From 80404329fafb9072b5286ee32616ac5387d24027 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Fri, 27 Oct 2023 11:16:56 +0200 Subject: [PATCH] ci: make tags `release-*` deploy to prod (#346) --- .github/actions/deploy/action.yaml | 6 +++--- .github/workflows/build.yaml | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/actions/deploy/action.yaml b/.github/actions/deploy/action.yaml index f90e8cd3..e61d7e34 100644 --- a/.github/actions/deploy/action.yaml +++ b/.github/actions/deploy/action.yaml @@ -31,6 +31,6 @@ runs: run: | 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 }} - shell: bash \ No newline at end of file +# - name: Invalidate CloudFront cache +# run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ inputs.cloudfront_distribution_id }} --paths ${{ inputs.cloudfront_invalidation_paths }} +# shell: bash \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e6db1bd8..ca47dc76 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,6 +17,7 @@ jobs: node-version: '18' - name: Install deps, build and test project uses: ./.github/actions/install + # Every push to main deploys to staging - name: Deploy to staging if: ${{ github.ref_name == 'main' }} uses: ./.github/actions/deploy @@ -26,4 +27,15 @@ jobs: aws_s3_sync_args: --include '*' --exclude '*/*' aws_s3_cache: no-store cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_STAGING }} + cloudfront_invalidation_paths: '/*' + # Only tags named as release-* will deploy to production + - name: Deploy to prod + if: startsWith(github.ref, 'refs/tags/release-') + uses: ./.github/actions/deploy + with: + aws_role: ${{ secrets.AWS_ROLE_PRODUCTION_ACCOUNT }} + aws_deploy_path: ${{ secrets.AWS_PRODUCTION_BUCKET }} + aws_s3_sync_args: --include '*' --exclude '*/*' + aws_s3_cache: max-age=3600 + cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_PRODUCTION }} cloudfront_invalidation_paths: '/*' \ No newline at end of file