1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-17 19:36:40 +00:00

add cache deletion for closed PRs

This commit is contained in:
yell0wsuit 2024-07-05 13:56:43 +07:00 committed by GitHub
parent c63053adf2
commit 1f49d59e6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,6 +11,10 @@ on:
- '!*.md'
- '.github/workflows/*.yml'
pull_request_target:
branches: [ master ]
types: [closed]
permissions:
pull-requests: write
checks: write
@ -72,3 +76,29 @@ jobs:
uses: ./.github/workflows/build.yml
needs: format
secrets: inherit
cleanup:
if: github.event.pull_request.merged == false
runs-on: ubuntu-latest
steps:
- name: Setup gh extension
run: |
gh extension install actions/gh-actions-cache
- name: Cleanup
run: |
echo "Fetching list of cache keys"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge