fix(ci): prevent "No space left on device" by cleaning up and using release build

This commit is contained in:
dab246
2025-09-29 11:06:11 +07:00
committed by Dat H. Pham
parent 38d64c4089
commit c15353ccad
2 changed files with 49 additions and 6 deletions
+46 -5
View File
@@ -5,6 +5,9 @@ on:
name: Deploy PR on Github Pages name: Deploy PR on Github Pages
env:
FLUTTER_VERSION: 3.27.4
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
@@ -17,33 +20,61 @@ jobs:
url: ${{ steps.configure.outputs.URL }} url: ${{ steps.configure.outputs.URL }}
steps: steps:
# 🧹 Free up space before building
- name: Free up disk space before build
run: |
echo "=== Disk space before cleanup ==="
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo apt-get clean
sudo apt-get autoclean
echo "=== Disk space after cleanup ==="
df -h
# 🔄 Checkout code
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup flutter # 🧰 Setup Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2
with: with:
flutter-version: "3.27.4" flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable" channel: "stable"
cache: true cache: true
cache-key: deps-${{ hashFiles('**/pubspec.lock') }} # optional, change this to force refresh cache cache-key: deps-${{ hashFiles('**/pubspec.lock') }} # optional, change this to force refresh cache
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
# 🧹 Clean Flutter cache before building
- name: Flutter clean
run: flutter clean
# 📦 Run prebuild (if any)
- name: Run prebuild - name: Run prebuild
run: ./scripts/prebuild.sh run: ./scripts/prebuild.sh
# ⚙️ Configure environment for PR
- name: Configure environments - name: Configure environments
id: configure id: configure
env: env:
FOLDER: ${{ github.event.pull_request.number }} FOLDER: ${{ github.event.pull_request.number }}
run: ./scripts/configure-web-environment.sh run: ./scripts/configure-web-environment.sh
- name: Build # 🧱 Build Flutter Web (release)
- name: Build Web (Release)
env: env:
FOLDER: ${{ github.event.pull_request.number }} FOLDER: ${{ github.event.pull_request.number }}
run: ./scripts/build-web.sh run: |
echo "=== Disk usage before build ==="
df -h
./scripts/build-web.sh
echo "=== Disk usage after build ==="
df -h
- name: Deploy to Github Pages # 🚀 Deploy to GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4 uses: peaceiris/actions-gh-pages@v4
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -51,6 +82,16 @@ jobs:
keep_files: true keep_files: true
publish_dir: "build/web" publish_dir: "build/web"
# 🧹 Clean up after build to save space
- name: Cleanup after deploy
if: always()
run: |
rm -rf build/
rm -rf .dart_tool/
echo "=== Disk usage after cleanup ==="
df -h
# 💬 Create or update comments on PR
- name: Find deployment comment - name: Find deployment comment
uses: peter-evans/find-comment@v3 uses: peter-evans/find-comment@v3
id: fc id: fc
+3 -1
View File
@@ -1,4 +1,6 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -eux set -eux
flutter build web --profile --verbose --base-href "/${GITHUB_REPOSITORY##*/}/$FOLDER/"
# Build web in release mode (lightweight, optimized)
flutter build web --release --base-href "/${GITHUB_REPOSITORY##*/}/$FOLDER/"