Skip to content

Commit 864395e

Browse files
committed
fix(ci): prevent "No space left on device" by cleaning up and using release build
1 parent 387b401 commit 864395e

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

.github/workflows/gh-pages.yaml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55

66
name: Deploy PR on Github Pages
77

8+
env:
9+
FLUTTER_VERSION: 3.27.4
10+
811
concurrency:
912
group: ${{ github.workflow }}-${{ github.ref }}
1013

@@ -17,40 +20,78 @@ jobs:
1720
url: ${{ steps.configure.outputs.URL }}
1821

1922
steps:
23+
# 🧹 Free up space before building
24+
- name: Free up disk space before build
25+
run: |
26+
echo "=== Disk space before cleanup ==="
27+
df -h
28+
sudo rm -rf /usr/share/dotnet
29+
sudo rm -rf /usr/local/lib/android
30+
sudo rm -rf /opt/ghc
31+
sudo apt-get clean
32+
sudo apt-get autoclean
33+
echo "=== Disk space after cleanup ==="
34+
df -h
35+
36+
# 🔄 Checkout code
2037
- name: Checkout repository
2138
uses: actions/checkout@v4
2239

23-
- name: Setup flutter
40+
# 🧰 Setup Flutter
41+
- name: Setup Flutter
2442
uses: subosito/flutter-action@v2
2543
with:
26-
flutter-version: "3.27.4"
44+
flutter-version: ${{ env.FLUTTER_VERSION }}
2745
channel: "stable"
2846
cache: true
2947
cache-key: deps-${{ hashFiles('**/pubspec.lock') }} # optional, change this to force refresh cache
3048
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
3149

50+
# 🧹 Clean Flutter cache before building
51+
- name: Flutter clean
52+
run: flutter clean
53+
54+
# 📦 Run prebuild (if any)
3255
- name: Run prebuild
3356
run: ./scripts/prebuild.sh
3457

58+
# ⚙️ Configure environment for PR
3559
- name: Configure environments
3660
id: configure
3761
env:
3862
FOLDER: ${{ github.event.pull_request.number }}
3963
run: ./scripts/configure-web-environment.sh
4064

41-
- name: Build
65+
# 🧱 Build Flutter Web (release)
66+
- name: Build Web (Release)
4267
env:
4368
FOLDER: ${{ github.event.pull_request.number }}
44-
run: ./scripts/build-web.sh
69+
run: |
70+
echo "=== Disk usage before build ==="
71+
df -h
72+
./scripts/build-web.sh
73+
echo "=== Disk usage after build ==="
74+
df -h
4575
46-
- name: Deploy to Github Pages
76+
# 🚀 Deploy to GitHub Pages
77+
- name: Deploy to GitHub Pages
4778
uses: peaceiris/actions-gh-pages@v4
4879
with:
4980
github_token: ${{ secrets.GITHUB_TOKEN }}
5081
destination_dir: ${{ github.event.pull_request.number }}
5182
keep_files: true
5283
publish_dir: "build/web"
5384

85+
# 🧹 Clean up after build to save space
86+
- name: Cleanup after deploy
87+
if: always()
88+
run: |
89+
rm -rf build/
90+
rm -rf .dart_tool/
91+
echo "=== Disk usage after cleanup ==="
92+
df -h
93+
94+
# 💬 Create or update comments on PR
5495
- name: Find deployment comment
5596
uses: peter-evans/find-comment@v3
5697
id: fc

scripts/build-web.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env sh
22

33
set -eux
4-
flutter build web --profile --verbose --base-href "/${GITHUB_REPOSITORY##*/}/$FOLDER/"
4+
5+
# Build web in release mode (lightweight, optimized)
6+
flutter build web --release --base-href "/${GITHUB_REPOSITORY##*/}/$FOLDER/"

0 commit comments

Comments
 (0)