From ee35c12aa72897f47486809a14580ce5f20e1258 Mon Sep 17 00:00:00 2001 From: abcampo-iry <261805581+abcampo-iry@users.noreply.github.com> Date: Wed, 13 May 2026 11:36:34 +0200 Subject: [PATCH 1/2] purge files --- .github/workflows/deploy.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b9e916af8..a0657703f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -172,7 +172,7 @@ jobs: exit 0 fi - echo -n "${{ needs.setup-environment.outputs.deploy_dir }}" | aws s3 cp - s3://${{ secrets.AWS_S3_BUCKET }}/latest_version --endpoint ${{ secrets.AWS_ENDPOINT }} --content-type "text/plain" + echo -n "${{ needs.setup-environment.outputs.deploy_dir }}" | aws s3 cp - s3://${{ secrets.AWS_S3_BUCKET }}/latest_version --endpoint ${{ secrets.AWS_ENDPOINT }} --content-type "text/plain" --cache-control "no-cache" env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -181,11 +181,26 @@ jobs: - name: Purge Cloudflare cache if: env.HAS_CLOUDFLARE_SECRETS == 'true' run: | + purge_payload="$( + jq -cn \ + --arg public_url "${{ needs.setup-environment.outputs.public_url }}" \ + --arg html_renderer_url "${{ needs.setup-environment.outputs.html_renderer_url }}" \ + --arg latest_version_url "${{ inputs.base_url }}/latest_version" \ + '[($public_url + "/"), ($html_renderer_url + "/"), $latest_version_url] + | map(sub("^https?://"; "")) + | map(gsub("/+"; "/")) + | unique + | {prefixes: .}' + )" + + echo "Purging Cloudflare cache prefixes:" + jq -r '.prefixes[] | " - \(.)"' <<<"$purge_payload" + response="$( curl -sS --fail-with-body -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \ -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ -H "Content-Type: application/json" \ - --data '{"files":["${{ needs.setup-environment.outputs.public_url }}/web-component.html", "${{ needs.setup-environment.outputs.public_url }}/web-component.js", "${{ needs.setup-environment.outputs.public_url }}/scratch.html", "${{ needs.setup-environment.outputs.public_url }}/scratch.js", "${{ inputs.base_url }}/latest_version", "${{ needs.setup-environment.outputs.html_renderer_url}}/html-renderer.html", "${{ needs.setup-environment.outputs.html_renderer_url}}/html-renderer.js"]}' + --data "$purge_payload" )" || { echo "Cloudflare purge request failed:" echo "$response" From 4660b12d1357499b4a90f8c7217287d831ff4570 Mon Sep 17 00:00:00 2001 From: abcampo-iry <261805581+abcampo-iry@users.noreply.github.com> Date: Wed, 13 May 2026 12:18:01 +0200 Subject: [PATCH 2/2] aligning with the rest of the logic --- .github/workflows/deploy.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a0657703f..6e119dc15 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -181,12 +181,18 @@ jobs: - name: Purge Cloudflare cache if: env.HAS_CLOUDFLARE_SECRETS == 'true' run: | + latest_version_url="" + if [ "${{ github.ref_type }}" = "tag" ]; then + latest_version_url="${{ inputs.base_url }}/latest_version" + fi + purge_payload="$( jq -cn \ --arg public_url "${{ needs.setup-environment.outputs.public_url }}" \ --arg html_renderer_url "${{ needs.setup-environment.outputs.html_renderer_url }}" \ - --arg latest_version_url "${{ inputs.base_url }}/latest_version" \ + --arg latest_version_url "$latest_version_url" \ '[($public_url + "/"), ($html_renderer_url + "/"), $latest_version_url] + | map(select(length > 0)) | map(sub("^https?://"; "")) | map(gsub("/+"; "/")) | unique