From 1c06c25ffbfb2dd07b098ab883b9c0344f5cc073 Mon Sep 17 00:00:00 2001 From: Giacomo Licari Date: Mon, 27 May 2024 18:11:21 +0200 Subject: [PATCH] CI: add cache invalidation --- .github/workflows/{dev_ci.yml => dev_deploy.yml} | 14 +++++++++----- .github/workflows/prod_deploy.yml | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) rename .github/workflows/{dev_ci.yml => dev_deploy.yml} (86%) diff --git a/.github/workflows/dev_ci.yml b/.github/workflows/dev_deploy.yml similarity index 86% rename from .github/workflows/dev_ci.yml rename to .github/workflows/dev_deploy.yml index 2efe442..059eeeb 100644 --- a/.github/workflows/dev_ci.yml +++ b/.github/workflows/dev_deploy.yml @@ -54,14 +54,18 @@ jobs: - name: 'Deploy to S3: Development' if: github.ref == 'refs/heads/dev' run: | - aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/dev --exclude "*.html" --cache-control max-age=0,no-cache,no-store,public - aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/dev --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html + aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/dev --exclude "*.html" --cache-control max-age=0,no-cache,no-store,public --delete + aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/dev --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html --delete aws s3 sync data s3://${{ secrets.DEV_BUCKET_NAME }}/dev/data --delete # Script to deploy to staging environment - name: 'Deploy to S3: Staging' if: github.ref == 'refs/heads/main' run: | - aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/main --exclude "*.html" --cache-control max-age=0,no-cache,no-store,public - aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/main --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html - aws s3 sync data s3://${{ secrets.DEV_BUCKET_NAME }}/main/data --delete \ No newline at end of file + aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/main --exclude "*.html" --cache-control max-age=0,no-cache,no-store,public --delete + aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/main --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html --delete + aws s3 sync data s3://${{ secrets.DEV_BUCKET_NAME }}/main/data --delete + + - name: 'Cloudfront: cache invalidation' + run: | + aws cloudfront create-invalidation --distribution-id ${{ secrets.DEV_AWS_CLOUDFRONT_ID }} --paths "/*" \ No newline at end of file diff --git a/.github/workflows/prod_deploy.yml b/.github/workflows/prod_deploy.yml index 2a90bef..366d625 100644 --- a/.github/workflows/prod_deploy.yml +++ b/.github/workflows/prod_deploy.yml @@ -69,6 +69,10 @@ jobs: aws s3 sync build/ s3://${{ secrets.RELEASE_BUCKET_NAME }} --delete --exclude "*" --include "sitemap.xml" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/xml aws s3 sync data s3://${{ secrets.RELEASE_BUCKET_NAME }}/data --delete + - name: 'Cloudfront: cache invalidation' + run: | + aws cloudfront create-invalidation --distribution-id ${{ secrets.PROD_AWS_CLOUDFRONT_ID }} --paths "/*" + notify: uses: ./.github/workflows/slack_release_notification.yml if: ${{ always() }}