Skip to content

Commit 9f8713c

Browse files
authored
gh-actions/diskspace: Add (default) background mode and output related pids (#2949)
Signed-off-by: Ryan Northey <ryan@synca.io> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 3e13975 commit 9f8713c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

gh-actions/diskspace/action.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ inputs:
22
to_remove:
33
type: string
44
default:
5+
background:
6+
type: boolean
7+
default: true
8+
description: "Run removal commands in background (true) or foreground (false). When true, returns immediately with PIDs as outputs."
59

10+
outputs:
11+
pids:
12+
description: "Space-separated list of background process PIDs (only set when background: true)"
13+
value: ${{ steps.remove_cruft.outputs.pids }}
614

715
runs:
816
using: composite
@@ -17,11 +25,23 @@ runs:
1725
else
1826
TO_REMOVE=(${DEFAULT_DIRECTORIES})
1927
fi
28+
if [[ "${{ inputs.background }}" == "true" ]]; then
29+
# Run rm commands in background
30+
pids=()
31+
for removal in "${TO_REMOVE[@]}"; do
32+
echo "Removing: ${removal} (background) ..."
33+
sudo rm -rf "$removal" &
34+
pids+=($!)
35+
done
36+
echo "pids=${pids[*]}" >> $GITHUB_OUTPUT
37+
echo "Background removal started with PIDs: ${pids[*]}"
38+
exit 0
39+
fi
40+
# Run rm commands in foreground
2041
for removal in "${TO_REMOVE[@]}"; do
2142
echo "Removing: ${removal} ..."
2243
sudo rm -rf "$removal"
2344
done
24-
2545
echo "Disk after cruft removal"
2646
df -h
2747
env:

0 commit comments

Comments
 (0)