Skip to content

Commit

Permalink
remove cloudfront invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
blotus committed Dec 18, 2024
1 parent 4da98bc commit a19c8a4
Showing 1 changed file with 0 additions and 60 deletions.
60 changes: 0 additions & 60 deletions .github/workflows/update-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,6 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

check-secret:
runs-on: ubuntu-latest
outputs:
secret-exists: ${{ steps.check.outputs.exists }}
steps:
- name: Check for Secret availability
id: check
shell: bash
run: |
if [ "${{ secrets.CF_DISTRIBUTION_ID }}" != '' ]; then
echo "exists=true" >> $GITHUB_OUTPUT;
else
echo "exists=false" >> $GITHUB_OUTPUT;
fi

run-linter:
runs-on: ubuntu-latest
Expand All @@ -94,48 +79,3 @@ jobs:
run: |
pipenv run ./hublint defaults > .hublint.toml
pipenv run ./hublint check --color always --no-warning-details
invalidate-cache:
runs-on: ubuntu-latest
needs:
- build
- check-secret
- run-linter
if: needs.check-secret.outputs.secret-exists == 'true'
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CF_AWS_ROLE }}
role-session-name: github-action
aws-region: eu-west-1
mask-aws-account-id: true
- name: Get branch name
run: echo "version=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Get changed files
run: |
changed_files=$(git diff-tree --no-commit-id --name-only -r $GITHUB_SHA | tr '\n' ',' | sed 's/,$/\n/')
echo "changed_files=${changed_files}" >> $GITHUB_ENV
- name: Invalidate cache
run: |
create_invalidation() {
#$1 is not quotted on purpose, so it can be expanded to multiple arguments
aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DISTRIBUTION_ID }} --paths $1
}
PATHS="/${{ env.version }}/.index.json"
IFS=',' read -ra FILE <<< "${{ env.changed_files }}"
for i in "${FILE[@]}"; do
PATHS="$PATHS /${{ env.version }}/$i"
done
echo "Invalidating paths: $PATHS"
for ((i=0; i < 3; i++)); do
create_invalidation "$PATHS" && break || echo "Invalidation failed, retrying in 5 seconds..."
sleep 5
done

0 comments on commit a19c8a4

Please sign in to comment.