mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 01:40:46 +08:00
34 lines
966 B
YAML
34 lines
966 B
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: |
|
|
mkdir -p temp && cd "$_"
|
|
|
|
git init
|
|
git remote add origin https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
|
|
|
|
PR_NUMBER=${{ github.event.pull_request.number }}
|
|
echo "PR Number: $PR_NUMBER"
|
|
|
|
cache_list=$(gh cache list --json id,ref | jq -r ".[] | select(.ref | test(\"refs/pull/$PR_NUMBER/merge\")) | .id")
|
|
|
|
if [ -n "$cache_list" ]; then
|
|
for cache_id in $cache_list; do
|
|
echo "Deleting cache with ID: $cache_id"
|
|
gh cache delete $cache_id
|
|
done
|
|
else
|
|
echo "No cache found for PR #$pr_number"
|
|
fi
|