mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-19 23:12:40 +08:00
ci: free disk on GH runner, prune Docker cache, and reliable self-hosted fallback
- Add “Free Disk Space (Ubuntu)” and Docker prune steps before/after the GitHub-hosted build to recover tens of GB and avoid “no space left on device” failures on ubuntu-latest. - Remove continue-on-error and gate the self-hosted job with `always() && needs.build-gh.result != 'success'` so it runs only if the GH build fails, while publish proceeds if either path succeeds. - Enable buildx GHA cache (cache-from/cache-to) to minimize runner disk pressure and rebuild times without loading images locally.
This commit is contained in:
parent
79c06245ff
commit
dea2903ce2
50
.github/workflows/build-release.yml
vendored
50
.github/workflows/build-release.yml
vendored
@ -20,6 +20,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Install prerequisites (jq, curl)
|
- name: Install prerequisites (jq, curl)
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@ -27,6 +28,7 @@ jobs:
|
|||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get install -y jq curl
|
sudo apt-get install -y jq curl
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Determine current tag (release, then git fallback)
|
- name: Determine current tag (release, then git fallback)
|
||||||
id: resolve
|
id: resolve
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -47,14 +49,34 @@ jobs:
|
|||||||
name: Build on GitHub Runner (primary)
|
name: Build on GitHub Runner (primary)
|
||||||
needs: check-tag
|
needs: check-tag
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
|
||||||
build_succeeded: ${{ steps.set_out.outputs.succeeded }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
|
||||||
|
- name: Show disk usage (pre)
|
||||||
|
run: df -h | sed 's/\s\+/ /g'
|
||||||
|
|
||||||
|
- name: Free Disk Space (Ubuntu)
|
||||||
|
uses: jlumbroso/free-disk-space@main
|
||||||
|
with:
|
||||||
|
tool-cache: false
|
||||||
|
android: true
|
||||||
|
dotnet: true
|
||||||
|
haskell: true
|
||||||
|
large-packages: true
|
||||||
|
docker-images: true
|
||||||
|
swap-storage: true
|
||||||
|
|
||||||
|
- name: Prune Docker caches (pre)
|
||||||
|
run: |
|
||||||
|
docker builder prune -af || true
|
||||||
|
docker system prune -af --volumes || true
|
||||||
|
|
||||||
|
- name: Show disk usage (post-clean)
|
||||||
|
run: df -h | sed 's/\s\+/ /g'
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
@ -89,7 +111,6 @@ jobs:
|
|||||||
- name: Build and Push (GH runner)
|
- name: Build and Push (GH runner)
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
continue-on-error: true
|
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
@ -97,19 +118,22 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
provenance: false
|
provenance: false
|
||||||
sbom: false
|
sbom: false
|
||||||
|
cache-from: type=gha,scope=gh
|
||||||
|
cache-to: type=gha,mode=max,scope=gh
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.IMAGE_NAME }}:${{ needs.check-tag.outputs.current_tag }}
|
${{ env.IMAGE_NAME }}:${{ needs.check-tag.outputs.current_tag }}
|
||||||
${{ env.IMAGE_NAME }}:latest
|
${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
- name: Set outcome flag
|
- name: Prune Docker caches (post)
|
||||||
id: set_out
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
echo "succeeded=${{ steps.build.outcome == 'success' }}" >> "$GITHUB_OUTPUT"
|
docker builder prune -af || true
|
||||||
|
docker system prune -af --volumes || true
|
||||||
|
|
||||||
build-self:
|
build-self:
|
||||||
name: Build on Self-Hosted (fallback)
|
name: Build on Self-Hosted (fallback)
|
||||||
needs: [check-tag, build-gh]
|
needs: [check-tag, build-gh]
|
||||||
if: needs.build-gh.outputs.build_succeeded != 'true'
|
if: ${{ always() && needs.build-gh.result != 'success' }}
|
||||||
runs-on: [self-hosted, linux, x64, homelab]
|
runs-on: [self-hosted, linux, x64, homelab]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -157,14 +181,22 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
provenance: false
|
provenance: false
|
||||||
sbom: false
|
sbom: false
|
||||||
|
cache-from: type=gha,scope=gh
|
||||||
|
cache-to: type=gha,mode=max,scope=gh
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.IMAGE_NAME }}:${{ needs.check-tag.outputs.current_tag }}
|
${{ env.IMAGE_NAME }}:${{ needs.check-tag.outputs.current_tag }}
|
||||||
${{ env.IMAGE_NAME }}:latest
|
${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
|
- name: Prune Docker caches (post)
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker builder prune -af || true
|
||||||
|
docker system prune -af --volumes || true
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
name: Update Release
|
name: Update Release
|
||||||
needs: [check-tag, build-gh, build-self]
|
needs: [check-tag, build-gh, build-self]
|
||||||
if: always() && (needs.build-gh.outputs.build_succeeded == 'true' || needs.build-self.result == 'success')
|
if: ${{ always() && (needs.build-gh.result == 'success' || needs.build-self.result == 'success') }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Update GitHub Release (same tag)
|
- name: Update GitHub Release (same tag)
|
||||||
@ -188,7 +220,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fail if both build paths failed
|
- name: Fail if both build paths failed
|
||||||
if: ${{ !(needs.build-gh.outputs.build_succeeded == 'true' || needs.build-self.result == 'success') }}
|
if: ${{ !(needs.build-gh.result == 'success' || needs.build-self.result == 'success') }}
|
||||||
run: |
|
run: |
|
||||||
echo "Manual rebuild failed on both GitHub-hosted and self-hosted paths."
|
echo "Manual rebuild failed on both GitHub-hosted and self-hosted paths."
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user