mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 12:38:43 +00:00

since cache-cleanup will issue a lot of gh api requests, running the workflow right after the PRs would cause the GH API to rate limit all workflows (including our CI for testing and release) that they can no longer upload artifacts and `cargo-binstall` would have to fallback to sending GET requests instead of using GH API, which makes it a lot slower and more likely to fail. This PR changes it to be run at 3am and 4:30am AEST which nobody would submit any PR at that time and then remove all caches of the top 20 closed prs. The workflow can also now be triggered manually. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
25 lines
599 B
Bash
Executable file
25 lines
599 B
Bash
Executable file
#!/bin/bash
|
|
|
|
set -uxo pipefail
|
|
|
|
REPO="${REPO?}"
|
|
BRANCH="${BRANCH?}"
|
|
|
|
while true; do
|
|
echo "Fetching list of cache key for $BRANCH"
|
|
cacheKeysForPR="$(gh actions-cache list -R "$REPO" -B "$BRANCH" -L 100 | cut -f 1 )"
|
|
|
|
if [ -z "$cacheKeysForPR" ]; then
|
|
break
|
|
fi
|
|
|
|
## Setting this to not fail the workflow while deleting cache keys.
|
|
set +e
|
|
echo "Deleting caches..."
|
|
for cacheKey in $cacheKeysForPR
|
|
do
|
|
echo Removing "$cacheKey"
|
|
gh actions-cache delete "$cacheKey" -R "$REPO" -B "$BRANCH" --confirm
|
|
done
|
|
done
|
|
echo "Done cleaning up $BRANCH"
|