diff --git a/.github/workflows/aws.yaml b/.github/workflows/aws.yaml index ef57cd0..33c94a4 100644 --- a/.github/workflows/aws.yaml +++ b/.github/workflows/aws.yaml @@ -39,3 +39,10 @@ jobs: run: | chmod +x scripts/deploy.sh scripts/deploy.sh + + - name: Invalidate CloudFront cache + env: + AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} + run: | + chmod +x scripts/invalidate.sh + scripts/invalidate.sh diff --git a/scripts/invalidate.sh b/scripts/invalidate.sh new file mode 100644 index 0000000..a491c17 --- /dev/null +++ b/scripts/invalidate.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ -z "$AWS_CLOUDFRONT_DISTRIBUTION_ID" ]; then + echo 'No cloudfront distribution id found.' + exit 1 +fi + +aws cloudfront create-invalidation --distribution-id "$AWS_CLOUDFRONT_DISTRIBUTION_ID" --paths "/*"