diff --git a/.github/workflows/purge_cache.yaml b/.github/workflows/purge_cache.yaml new file mode 100644 index 0000000..d7b45ff --- /dev/null +++ b/.github/workflows/purge_cache.yaml @@ -0,0 +1,36 @@ +name: Purge Front Door Cache + +on: + # Run this workflow from other workflows + workflow_call: + inputs: + fdname: + description: 'Front Door Name' + required: true + type: string + path: + description: 'Content path to purge' + required: true + type: string + secrets: + creds: + required: true + +jobs: + purge_cache: + runs-on: ubuntu-latest + steps: + - name: Log in + uses: azure/login@v2 + with: + creds: ${{ secrets.creds }} + + - name: Purge Cache Path + id: upload + uses: azure/CLI@v2 + with: + inlineScript: | + az network front-door purge-endpoint \ + --resource-group 'static-sites' \ + --name '${{ inputs.fdname }}' \ + --content-paths '${{ inputs.path }}' diff --git a/.github/workflows/test_cache_purge.yaml b/.github/workflows/test_cache_purge.yaml new file mode 100644 index 0000000..2dc0706 --- /dev/null +++ b/.github/workflows/test_cache_purge.yaml @@ -0,0 +1,15 @@ +name: Test Cache Purge + +on: + pull_request: + workflow_dispatch: + +jobs: + test_cache_purge: + name: Purge cached file + uses: ./.github/workflows/purge_cache.yaml + with: + fdname: 'frontend-preview-zooniverse-org' + path: '/assets/star.jpg' + secrets: + creds: ${{ secrets.AZURE_STATIC_SITES }} diff --git a/README.md b/README.md index 8ab0d94..954c87e 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,25 @@ jobs: creds: ${{ secrets.AZURE_STATIC_SITES }} ``` +### Purge the Front Door cache for a specific AFD instance and content path +```yaml +name: Purge Star +on: + push: + tags: + - production-release + +jobs: + purge_cached_star: + name: Purge cached file + uses: zooniverse/ci-cd/.github/workflows/purge_cache.yaml@main + with: + fdname: 'frontend-preview-zooniverse-org' + path: '/assets/star.jpg' + secrets: + creds: ${{ secrets.AZURE_STATIC_SITES }} +``` + ### Send a Slack notification ```yaml slack_notification: