Skip to content

Commit d214d29

Browse files
committed
Fix GitHub Actions disk space issues
- Add centralized disk cleanup script (.github/scripts/free-disk-space.sh) - Update root workflows to use script: test-build.yml, test-build-packages.yml, test-build-docker.yml, test-build-distributor.yml - Update PR-build.yml to use script (Linux only) - Frees ~20GB by removing .NET, Android SDK, Haskell, CodeQL tools Fixes 'No space left on device' errors in build workflows
1 parent 963ad10 commit d214d29

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

.github/scripts/free-disk-space.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "=== Disk usage before cleanup ==="
5+
df -h
6+
7+
echo "=== Freeing up disk space ==="
8+
sudo rm -rf /usr/share/dotnet
9+
sudo rm -rf /usr/local/share/powershell
10+
sudo rm -rf /usr/local/lib/android
11+
sudo rm -rf /opt/ghc
12+
sudo rm -rf /opt/hostedtoolcache/CodeQL
13+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
14+
15+
echo "=== Disk usage after cleanup ==="
16+
df -h

.github/workflows/PR-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ jobs:
112112
if: needs.changes.outputs.build == 'true'
113113
uses: actions/checkout@v3
114114

115+
- name: Free up disk space
116+
if: needs.changes.outputs.build == 'true' && matrix.family == 'linux'
117+
run: .github/scripts/free-disk-space.sh
118+
115119
- name: Cache binaries
116120
id: cached_binaries
117121
if: needs.changes.outputs.build == 'true'

.github/workflows/test-build-distributor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ jobs:
8383
role-to-assume: ${{ inputs.TerraformAWSAssumeRole }}
8484
aws-region: ${{ inputs.Region }}
8585

86+
- name: Free up disk space
87+
run: .github/scripts/free-disk-space.sh
88+
8689
- name: Agent Version
8790
id: version
8891
run: |

.github/workflows/test-build-docker.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ jobs:
6565
role-to-assume: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
6666
aws-region: us-west-2
6767

68+
- name: Free up disk space
69+
run: .github/scripts/free-disk-space.sh
70+
6871
- name: Cache container
6972
id: cached_container
7073
uses: actions/cache@v3

.github/workflows/test-build-packages.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ jobs:
8282
with:
8383
go-version: ~1.22.2
8484

85+
- name: Free up disk space
86+
run: .github/scripts/free-disk-space.sh
87+
8588
- name: Configure AWS Credentials
8689
uses: aws-actions/configure-aws-credentials@v4
8790
with:

.github/workflows/test-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ jobs:
7878
go-version: ~1.22.2
7979
cache: false
8080

81+
- name: Free up disk space
82+
run: .github/scripts/free-disk-space.sh
83+
8184
- name: Install rpm
8285
run: sudo apt install rpm
8386

0 commit comments

Comments
 (0)