Skip to content

Commit 2fe368e

Browse files
committed
internal/ci: simplify and improve clearing of all cache entries
actions/gh-actions-cache is now deprecated in favor of the new built-in `gh cache` command, which luckily includes flags to select a repository, delete all of its cache entries, and succeed if there is nothing to delete at all. Tested manually on a repository of mine that this works as intended. Now that the script is much simpler, we don't need `set -x` either. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I09d6044d69584bf4590cf51a407e87fdbc3264df Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211352 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Paul Jolly <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent e919342 commit 2fe368e

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

.github/workflows/evict_caches.yaml

+1-10
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,11 @@ jobs:
4848
false
4949
- name: Delete caches
5050
run: |-
51-
set -x
52-
5351
echo ${{ secrets.CUECKOO_GITHUB_PAT }} | gh auth login --with-token
54-
gh extension install actions/gh-actions-cache
5552
for i in https://github.com/cue-lang/cue https://github.com/cue-lang/cue-trybot
5653
do
5754
echo "Evicting caches for $i"
58-
cd $(mktemp -d)
59-
git init -b initialbranch
60-
git remote add origin $i
61-
for j in $(gh actions-cache list -L 100 | grep refs/ | awk '{print $1}')
62-
do
63-
gh actions-cache delete --confirm $j
64-
done
55+
gh cache delete --repo $i --all --succeed-on-no-caches
6556
done
6657
- name: Trigger workflow runs to repopulate caches
6758
run: |-

internal/ci/base/gerrithub.cue

+1-10
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,11 @@ evictCaches: bashWorkflow & {
248248
githubactions.#Step & {
249249
name: "Delete caches"
250250
run: """
251-
set -x
252-
253251
echo ${{ secrets.\(botGitHubUserTokenSecretsKey) }} | gh auth login --with-token
254-
gh extension install actions/gh-actions-cache
255252
for i in \(githubRepositoryURL) \(trybotRepositoryURL)
256253
do
257254
echo "Evicting caches for $i"
258-
cd $(mktemp -d)
259-
git init -b initialbranch
260-
git remote add origin $i
261-
for j in $(gh actions-cache list -L 100 | grep refs/ | awk '{print $1}')
262-
do
263-
gh actions-cache delete --confirm $j
264-
done
255+
gh cache delete --repo $i --all --succeed-on-no-caches
265256
done
266257
"""
267258
},

0 commit comments

Comments
 (0)