mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
CI: Add workflow to cleanup PR caches when closed
This is pretty much copied from the GitHub Actions documentation: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
This commit is contained in:
parent
701505eb4f
commit
fd96ba48c6
1 changed files with 28 additions and 0 deletions
28
.github/workflows/cache_cleanup.yml
vendored
Normal file
28
.github/workflows/cache_cleanup.yml
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
|
||||||
|
name: 🧹 Cache Cleanup
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cleanup:
|
||||||
|
name: Cleanup PR caches
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Cleanup
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||||
|
run: |
|
||||||
|
echo "Fetching list of cache key"
|
||||||
|
cache_keys_for_pr=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
|
||||||
|
# Setting this to not fail the workflow while deleting cache keys.
|
||||||
|
set +e
|
||||||
|
echo "Deleting caches..."
|
||||||
|
for cache_key in $cache_keys_for_pr; do
|
||||||
|
gh cache delete $cache_key
|
||||||
|
echo "Deleted: $cache_key"
|
||||||
|
done
|
||||||
|
echo "Done"
|
Loading…
Add table
Add a link
Reference in a new issue