From d0f82600ccdf5e3edb50f3db055ccdb9e788c446 Mon Sep 17 00:00:00 2001 From: Scott Prutton Date: Tue, 25 Jun 2024 16:44:13 -0400 Subject: [PATCH] feat: remove artifact cache invalidation --- .github/workflows/deploy-service.yml | 23 ++++++++++------- .github/workflows/deploy-stack.yml | 8 +----- .github/workflows/invalidate-cache.yml | 34 -------------------------- 3 files changed, 15 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/invalidate-cache.yml diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 00b1f2441e..fee89daf94 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -32,7 +32,6 @@ jobs: aws-region: us-east-1 - name: Deploy web - id: deploy-web if: ${{ inputs.service == 'web' }} run: | ENVIRONMENT="${{ inputs.environment }}" @@ -80,6 +79,20 @@ jobs: exit 1 fi + - name: Invalidate web cache + if: ${{ inputs.service == 'web' }} + run: | + ENV=${{ inputs.environment }} + DIST_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='$ENV-cdn'].Id | [0]" --output text) + # Create a CloudFront invalidation for all objects (/*) + invalidation_id=$(aws cloudfront create-invalidation --distribution-id $DIST_ID --paths "/*" --query 'Invalidation.Id' --output text) + # Check the status of the invalidation until it's completed + while [[ "$(aws cloudfront get-invalidation --distribution-id $DIST_ID --id $invalidation_id --query 'Invalidation.Status' --output text)" != "Completed" ]]; do + echo "Invalidation is still in progress. Waiting..." + sleep 5 + done + echo "Invalidation is complete." + - name: Deploy service if: ${{ inputs.service != 'web' }} run: | @@ -149,11 +162,3 @@ jobs: echo "Version $VERSION for $SERVICE not found in the artifacts registry. Skipping!" exit 1 fi - - invalidate-cache: - if: ${{ inputs.service == 'web' }} - needs: deploy - uses: ./.github/workflows/invalidate-cache.yml - with: - environment: ${{ inputs.environment }} - secrets: inherit diff --git a/.github/workflows/deploy-stack.yml b/.github/workflows/deploy-stack.yml index 75d349c753..0f076a7680 100644 --- a/.github/workflows/deploy-stack.yml +++ b/.github/workflows/deploy-stack.yml @@ -42,12 +42,6 @@ on: default: "stable" jobs: - invalidate-cache: - uses: ./.github/workflows/invalidate-cache.yml - with: - environment: shared - secrets: inherit - set-init: uses: ./.github/workflows/set-init-version.yml with: @@ -70,7 +64,7 @@ jobs: fi deploy-services: - needs: ["invalidate-cache", "define-deployment-matrix"] + needs: "define-deployment-matrix" strategy: fail-fast: false matrix: diff --git a/.github/workflows/invalidate-cache.yml b/.github/workflows/invalidate-cache.yml deleted file mode 100644 index 16c9a84c1a..0000000000 --- a/.github/workflows/invalidate-cache.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Invalidate Cloudfront - -on: - workflow_call: - inputs: - environment: - type: string - required: true - description: "which environment to invalidate" - -jobs: - invalidate-cache: - environment: ${{ inputs.environment }} - runs-on: ubuntu-latest - steps: - # invalidate Artifact Store Cloudfront so we get latest - - name: Configure AWS credentials for shared-prod - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} - aws-region: us-east-1 - - name: Invalidate Artifacts Cache - run: | - ENV=${{ inputs.environment }} - DIST_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='$ENV-cdn'].Id | [0]" --output text) - # Create a CloudFront invalidation for all objects (/*) - invalidation_id=$(aws cloudfront create-invalidation --distribution-id $DIST_ID --paths "/*" --query 'Invalidation.Id' --output text) - # Check the status of the invalidation until it's completed - while [[ "$(aws cloudfront get-invalidation --distribution-id $DIST_ID --id $invalidation_id --query 'Invalidation.Status' --output text)" != "Completed" ]]; do - echo "Invalidation is still in progress. Waiting..." - sleep 5 - done - echo "Invalidation is complete."