Skip to content

Commit 8865051

Browse files
committed
fix: address review feedback (sudo -n, DEBIAN_FRONTEND, timeouts, guards)
1 parent a9034f8 commit 8865051

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

.github/actions/host-cleanup-linux/action.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ runs:
1212
# may need to be adjusted as new software gets installed.
1313
# Use the `du` command to determine what can be uninstalled.
1414
15-
# Use sudo only when available (containers may not have it)
16-
if command -v sudo >/dev/null 2>&1; then
17-
SUDO="sudo"
15+
# Use sudo only when available and non-interactive (no password prompt)
16+
if command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then
17+
SUDO="sudo -n"
1818
else
1919
SUDO=""
2020
fi
2121
2222
echo "Disk space before cleanup:"
2323
df -h /
2424
25-
rm -rf ~/.cargo ~/.rustup ~/.dotnet
25+
rm -rf ~/.cargo ~/.rustup ~/.dotnet || true
2626
2727
$SUDO rm -rf /usr/share/swift || true
2828
$SUDO rm -rf /opt/microsoft/msedge || true
@@ -32,9 +32,14 @@ runs:
3232
$SUDO rm -rf /opt/ghc || true
3333
$SUDO rm -rf /opt/hostedtoolcache/CodeQL || true
3434
35-
$SUDO snap remove lxd || true
36-
$SUDO snap remove core20 || true
37-
$SUDO apt-get purge -y snapd || true
35+
if command -v snap >/dev/null 2>&1; then
36+
timeout 60s $SUDO snap remove lxd || true
37+
timeout 60s $SUDO snap remove core20 || true
38+
fi
39+
40+
if command -v apt-get >/dev/null 2>&1; then
41+
DEBIAN_FRONTEND=noninteractive timeout 120s $SUDO apt-get purge -y snapd || true
42+
fi
3843
3944
echo "Disk space after cleanup:"
40-
df -h /
45+
df -h /

0 commit comments

Comments
 (0)