Skip to content

Commit 7594e04

Browse files
committed
Fix cleanup scripts for space
1 parent 9ad461f commit 7594e04

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.github/workflows/cleanup-cache-postpr.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ jobs:
3131
set +e
3232
3333
keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH | cut -f 1)
34-
for k in "$keys"
34+
# $keys might contain spaces. Thus we set IFS to \n.
35+
IFS=$'\n'
36+
for k in $keys
3537
do
3638
gh actions-cache delete "$k" -R $REPO -B $BRANCH --confirm
3739
done
40+
unset IFS

.github/workflows/cleanup-cache.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
EVENT=${{ github.event.workflow_run.event }}
2828
2929
# Triggering workflow run name (e.g., LinuxClang)
30-
WORKFLOW_NAME=${{ github.event.workflow_run.name }}
30+
WORKFLOW_NAME="${{ github.event.workflow_run.name }}"
3131
3232
if [[ $EVENT == "pull_request" ]]; then
3333
gh run download ${{ github.event.workflow_run.id }} -n pr_number
@@ -45,16 +45,19 @@ jobs:
4545
# The goal is to keep the last used key of each job and delete all others.
4646
4747
# something like ccache-LinuxClang-
48-
keyprefix=ccache-${WORKFLOW_NAME}-
48+
keyprefix="ccache-${WORKFLOW_NAME}-"
4949
5050
cached_jobs=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key "$keyprefix" | awk -F '-git-' '{print $1}' | sort | uniq)
5151
5252
# cached_jobs is something like "ccache-LinuxClang-configure-1d ccache-LinuxClang-configure-2d".
53-
for j in "$cached_jobs"
53+
# It might also contain spaces. Thus we set IFS to \n.
54+
IFS=$'\n'
55+
for j in $cached_jobs
5456
do
5557
old_keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key "${j}-git-" --sort last-used | cut -f 1 | tail -n +2)
56-
for k in "$old_keys"
58+
for k in $old_keys
5759
do
5860
gh actions-cache delete "$k" -R $REPO -B $BRANCH --confirm
5961
done
6062
done
63+
unset IFS

0 commit comments

Comments
 (0)