mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
[RN][CI] enable gradle action cleanup + closed Prs
Enable `gradle-home-cache-cleanup` to attempt to limit the growth of the `gradle-home-v1-*` cache entries. When these entries grow too large bad things happen. See [1]. Added cleanup-pr-cache to remove cache entries created by a PR, when the PR is closed. [1] https://github.com/gradle/actions/blob/main/docs/setup-gradle.md#remove-unused-files-from-gradle-user-home-before-saving-to-the-cache Changelog: [Internal]
This commit is contained in:
@@ -7,3 +7,7 @@ runs:
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
gradle-version: wrapper
|
||||
# The gradle-home-v1 cache entry grows very, eventually failing the jobs
|
||||
# when extracted.
|
||||
gradle-home-cache-cleanup: true
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# From: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
|
||||
name: cleanup caches by a branch that was closed
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cleanup
|
||||
run: |
|
||||
gh extension install actions/gh-actions-cache
|
||||
|
||||
echo "Fetching list of cache key"
|
||||
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
|
||||
Reference in New Issue
Block a user