mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-15 13:02:35 +08:00
Replace job‑level continue‑on‑error with a step‑level setting and export build_succeeded from the docker/build‑push step to drive the fallback condition, guaranteeing the self‑hosted job runs whenever the GitHub runner fails (e.g., disk space) instead of being masked by a successful job conclusion. Update publish/finalize gating to rely on the explicit output flag (or self‑hosted success) so releases proceed only when at least one build path publishes successfully.
147 lines
4.1 KiB
YAML
147 lines
4.1 KiB
YAML
name: Manual Rebuild and Republish Image
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/comfyui-docker
|
|
|
|
jobs:
|
|
check-tag:
|
|
name: Resolve Current Tag
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
current_tag: ${{ steps.resolve.outputs.current_tag }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
- name: Install prerequisites (jq, curl)
|
|
run: |
|
|
set -e
|
|
if ! command -v jq >/dev/null 2>&1; then
|
|
sudo apt-get update -y
|
|
sudo apt-get install -y jq curl
|
|
fi
|
|
- name: Determine current tag (release, then git fallback)
|
|
id: resolve
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
REPO="${GITHUB_REPOSITORY}"
|
|
TAG=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | jq -r .tag_name || echo "")
|
|
if [ -z "${TAG}" ] || [ "${TAG}" = "null" ]; then
|
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null || true)
|
|
fi
|
|
if [ -z "${TAG}" ]; then
|
|
echo "No existing release or tag found; aborting." >&2
|
|
exit 1
|
|
fi
|
|
echo "current_tag=${TAG}" >> "$GITHUB_OUTPUT"
|
|
|
|
build-gh:
|
|
name: Build on GitHub Runner (primary)
|
|
needs: check-tag
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
build_succeeded: ${{ steps.set_out.outputs.succeeded }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
cleanup: true
|
|
|
|
- name: Check CR_PAT secret
|
|
id: crpat
|
|
shell: bash
|
|
run: |
|
|
if [ -n "${{ secrets.CR_PAT }}" ]; then
|
|
echo "present=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "present=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Login to GHCR with GITHUB_TOKEN
|
|
if: ${{ steps.crpat.outputs.present == 'false' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to GHCR with CR_PAT
|
|
if: ${{ steps.crpat.outputs.present == 'true' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.CR_PAT }}
|
|
|
|
- name: Build and Push (GH runner)
|
|
id: build
|
|
uses: docker/build-push-action@v6
|
|
continue-on-error: true
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64
|
|
push: true
|
|
provenance: false
|
|
sbom: false
|
|
tags: |
|
|
${{ env.IMAGE_NAME }}:${{ needs.check-tag.outputs.current_tag }}
|
|
${{ env.IMAGE_NAME }}:latest
|
|
|
|
- name: Set outcome flag
|
|
id: set_out
|
|
run: |
|
|
echo "succeeded=${{ steps.build.outcome == 'success' }}" >> "$GITHUB_OUTPUT"
|
|
|
|
build-self:
|
|
name: Build on Self-Hosted (fallback)
|
|
needs: [check-tag, build-gh]
|
|
if: needs.build-gh.outputs.build_succeeded != 'true'
|
|
runs-on: [self-hosted, linux, x64, homelab]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
cleanup: true
|
|
|
|
- name: Check CR_PAT secret
|
|
id: crpat
|
|
shell: bash
|
|
run: |
|
|
if [ -n "${{ secrets.CR_PAT }}" ]; then
|
|
echo "present=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "present=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Login to GHCR with GITHUB_TOKEN
|
|
if: ${{ steps.crpat.outputs.present == 'false' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to GHCR with CR_PAT
|
|
if: ${{ steps.crpat.outputs.present == 'true' }}
|
|
uses: docker/login-action@v3
|
|
with:
|