Build an Android APK
Build Android Release / Build Android (push) Failing after 40s

This commit is contained in:
2026-05-16 00:14:09 +08:00
parent a9738212cc
commit 31acfd4e13
+54
View File
@@ -20,6 +20,46 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Preflight disk cleanup
shell: bash
run: |
set -euo pipefail
run_sudo() {
if command -v sudo >/dev/null 2>&1; then
sudo "$@"
else
"$@"
fi
}
free_mb() {
df -Pm "${1:-/}" | awk 'NR==2 {print $4}'
}
echo "Disk usage before cleanup:"
df -h
if command -v docker >/dev/null 2>&1; then
docker system prune -af --volumes || true
docker builder prune -af || true
fi
run_sudo rm -rf /tmp/* /var/tmp/* || true
if [ "$(free_mb /)" -lt 8192 ]; then
echo "Free disk space is below 8GB. Cleaning user build caches..."
rm -rf "$HOME/.gradle/caches" "$HOME/.gradle/wrapper/dists" "$HOME/.pub-cache/_temp" || true
fi
echo "Disk usage after cleanup:"
df -h
if [ "$(free_mb /)" -lt 4096 ]; then
echo "Free disk space is still below 4GB after cleanup. Runner disk is effectively full."
exit 1
fi
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@@ -68,6 +108,8 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
rm -rf build dist .dart_tool android/.gradle
pkg_dir="$PWD/dist/android" pkg_dir="$PWD/dist/android"
if [ -d "$pkg_dir" ]; then if [ -d "$pkg_dir" ]; then
echo "Cleaning old Android build artifacts: $pkg_dir" echo "Cleaning old Android build artifacts: $pkg_dir"
@@ -202,3 +244,15 @@ jobs:
-H "Authorization: token $GITEA_TOKEN" \ -H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@gongyun-app-release.apk" \ -F "attachment=@gongyun-app-release.apk" \
"$assets_url?name=gongyun-app-release.apk" "$assets_url?name=gongyun-app-release.apk"
- name: Post-build disk cleanup
if: always()
shell: bash
run: |
set -euo pipefail
rm -rf build dist .dart_tool android/.gradle android/app-release.jks android/key.properties || true
if command -v docker >/dev/null 2>&1; then
docker system prune -af --volumes || true
docker builder prune -af || true
fi
df -h