Files
MaaAssistantArknights/.github/workflows/cache-delete.yml
2025-01-06 23:54:43 +01:00

30 lines
1.0 KiB
YAML

name: Delete Cache
on:
pull_request:
types: [closed]
jobs:
cache-delete:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Delete cache on PR merged
env:
GH_TOKEN: ${{ secrets.MAA_ACTION_READ_WRITE }}
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
echo "PR Number: $PR_NUMBER"
curl -s -L https://api.github.com/repos/Maaassistantarknights/Maaassistantarknights/actions/caches |
jq -r --arg PR_NUMBER "refs/pull/$PR_NUMBER/merge" '.actions_caches[] | select(.ref == $PR_NUMBER) | .id' |
while read -r id; do
echo "Deleting cache with ID: $id"
curl -L -X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.MAA_ACTION_READ_WRITE }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/MaaAssistantArknights/MaaAssistantArknights/actions/caches/$id"
done