Skip to content

Purge Caddy Cache

Purge Caddy Cache #5

Workflow file for this run

name: Purge Caddy Cache
on:
workflow_dispatch:
env:
GO_VERSION: '1.22'
jobs:
purge-cache:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- name: Get cache key
id: get-key
run: |
echo "cache_key=caddy-${{ runner.os }}-${GO_VERSION}-${{ hashFiles('**/go.sum') || 'no-deps' }}-2.9" >> $GITHUB_OUTPUT
- name: Delete cache
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "Attempting to delete cache with key: ${{ steps.get-key.outputs.cache_key }}"
CACHE_ID=$(gh api -H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/actions/caches" \
--jq ".actions_caches[] | select(.key == \"${{ steps.get-key.outputs.cache_key }}\") | .id")
if [ -n "$CACHE_ID" ]; then
echo "Found cache with ID: $CACHE_ID"
gh api --method DELETE \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/actions/caches/$CACHE_ID"
echo "Cache deleted successfully"
else
echo "No cache found with key: ${{ steps.get-key.outputs.cache_key }}"
exit 0
fi