Skip to content

Commit

Permalink
Merge pull request #87 from zooniverse/purge-cache-action
Browse files Browse the repository at this point in the history
Add Purge Front Door Cache action
  • Loading branch information
zwolf authored Oct 15, 2024
2 parents 60b779d + 0dcbbad commit 883367f
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/purge_cache.yaml
Original file line number Diff line number Diff line change
@@ -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 }}'
15 changes: 15 additions & 0 deletions .github/workflows/test_cache_purge.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 883367f

Please sign in to comment.