mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-07 07:42:32 +08:00
Refactor CI workflow conditions and cleanup steps
Updated conditions for build and publish steps in CI workflow.
This commit is contained in:
parent
327d7ea37f
commit
1da5dc48e6
57
.github/workflows/sync-build-release.yml
vendored
57
.github/workflows/sync-build-release.yml
vendored
@ -22,7 +22,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Install prerequisites (jq, curl, git)
|
- name: Install prerequisites (jq, curl, git)
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@ -30,7 +29,6 @@ jobs:
|
|||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get install -y jq curl git
|
sudo apt-get install -y jq curl git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Check for New Upstream Release
|
- name: Check for New Upstream Release
|
||||||
id: check_version
|
id: check_version
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -43,7 +41,6 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo "new_version=none" >> "$GITHUB_OUTPUT"
|
echo "new_version=none" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Cleanup workspace (always, scoped)
|
- name: Cleanup workspace (always, scoped)
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: |
|
run: |
|
||||||
@ -56,17 +53,18 @@ jobs:
|
|||||||
if: needs.check-upstream.outputs.new_version != 'none'
|
if: needs.check-upstream.outputs.new_version != 'none'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
outputs:
|
||||||
|
built: ${{ steps.mark.outputs.built }}
|
||||||
|
digest: ${{ steps.build.outputs.digest }}
|
||||||
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: Set Git Config
|
- name: Set Git Config
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "GitHub Actions"
|
git config --global user.name "GitHub Actions"
|
||||||
git config --global user.email "actions@github.com"
|
git config --global user.email "actions@github.com"
|
||||||
|
|
||||||
- name: Sync with Upstream (idempotent)
|
- name: Sync with Upstream (idempotent)
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@ -83,12 +81,10 @@ jobs:
|
|||||||
git add README.md
|
git add README.md
|
||||||
git commit -m "Merge upstream/master, keep local README.md" || true
|
git commit -m "Merge upstream/master, keep local README.md" || true
|
||||||
git push origin master
|
git push origin master
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
cleanup: true
|
cleanup: true
|
||||||
|
|
||||||
- name: Check CR_PAT secret
|
- name: Check CR_PAT secret
|
||||||
id: crpat
|
id: crpat
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -98,7 +94,6 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo "present=false" >> "$GITHUB_OUTPUT"
|
echo "present=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Login to GHCR with GITHUB_TOKEN
|
- name: Login to GHCR with GITHUB_TOKEN
|
||||||
if: ${{ steps.crpat.outputs.present == 'false' }}
|
if: ${{ steps.crpat.outputs.present == 'false' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@ -106,7 +101,6 @@ jobs:
|
|||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Login to GHCR with CR_PAT
|
- name: Login to GHCR with CR_PAT
|
||||||
if: ${{ steps.crpat.outputs.present == 'true' }}
|
if: ${{ steps.crpat.outputs.present == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@ -114,7 +108,6 @@ jobs:
|
|||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.CR_PAT }}
|
password: ${{ secrets.CR_PAT }}
|
||||||
|
|
||||||
- name: Free disk space (best effort)
|
- name: Free disk space (best effort)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
@ -122,8 +115,8 @@ jobs:
|
|||||||
sudo rm -rf /usr/local/lib/android || true
|
sudo rm -rf /usr/local/lib/android || true
|
||||||
sudo rm -rf /opt/ghc || true
|
sudo rm -rf /opt/ghc || true
|
||||||
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
|
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
|
||||||
|
|
||||||
- name: Build and Push (GH runner)
|
- name: Build and Push (GH runner)
|
||||||
|
id: build
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@ -135,23 +128,28 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
${{ env.IMAGE_NAME }}:${{ needs.check-upstream.outputs.new_version }}
|
${{ env.IMAGE_NAME }}:${{ needs.check-upstream.outputs.new_version }}
|
||||||
${{ env.IMAGE_NAME }}:latest
|
${{ env.IMAGE_NAME }}:latest
|
||||||
|
- name: Mark build success
|
||||||
|
id: mark
|
||||||
|
if: ${{ success() && steps.build.outputs.digest != '' }}
|
||||||
|
run: echo "built=true" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
build-self:
|
build-self:
|
||||||
name: Build on Self-Hosted (fallback)
|
name: Build on Self-Hosted (fallback)
|
||||||
needs: [check-upstream, build-gh]
|
needs: [check-upstream, build-gh]
|
||||||
if: needs.check-upstream.outputs.new_version != 'none' && needs.build-gh.result != 'success'
|
if: needs.check-upstream.outputs.new_version != 'none' && needs.build-gh.outputs.built != 'true'
|
||||||
runs-on: [self-hosted, linux, x64, homelab]
|
runs-on: [self-hosted, linux, x64, homelab]
|
||||||
|
outputs:
|
||||||
|
built: ${{ steps.mark.outputs.built }}
|
||||||
|
digest: ${{ steps.build.outputs.digest }}
|
||||||
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: Set Git Config
|
- name: Set Git Config
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "GitHub Actions"
|
git config --global user.name "GitHub Actions"
|
||||||
git config --global user.email "actions@github.com"
|
git config --global user.email "actions@github.com"
|
||||||
|
|
||||||
- name: Sync with Upstream (idempotent)
|
- name: Sync with Upstream (idempotent)
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@ -168,12 +166,10 @@ jobs:
|
|||||||
git add README.md
|
git add README.md
|
||||||
git commit -m "Merge upstream/master, keep local README.md" || true
|
git commit -m "Merge upstream/master, keep local README.md" || true
|
||||||
git push origin master
|
git push origin master
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
cleanup: true
|
cleanup: true
|
||||||
|
|
||||||
- name: Check CR_PAT secret
|
- name: Check CR_PAT secret
|
||||||
id: crpat
|
id: crpat
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -183,7 +179,6 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo "present=false" >> "$GITHUB_OUTPUT"
|
echo "present=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Login to GHCR with GITHUB_TOKEN
|
- name: Login to GHCR with GITHUB_TOKEN
|
||||||
if: ${{ steps.crpat.outputs.present == 'false' }}
|
if: ${{ steps.crpat.outputs.present == 'false' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@ -191,7 +186,6 @@ jobs:
|
|||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Login to GHCR with CR_PAT
|
- name: Login to GHCR with CR_PAT
|
||||||
if: ${{ steps.crpat.outputs.present == 'true' }}
|
if: ${{ steps.crpat.outputs.present == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@ -199,8 +193,8 @@ jobs:
|
|||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.CR_PAT }}
|
password: ${{ secrets.CR_PAT }}
|
||||||
|
|
||||||
- name: Build and Push (self-hosted)
|
- name: Build and Push (self-hosted)
|
||||||
|
id: build
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@ -212,14 +206,16 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
${{ env.IMAGE_NAME }}:${{ needs.check-upstream.outputs.new_version }}
|
${{ env.IMAGE_NAME }}:${{ needs.check-upstream.outputs.new_version }}
|
||||||
${{ env.IMAGE_NAME }}:latest
|
${{ env.IMAGE_NAME }}:latest
|
||||||
|
- name: Mark build success
|
||||||
|
id: mark
|
||||||
|
if: ${{ success() && steps.build.outputs.digest != '' }}
|
||||||
|
run: echo "built=true" >> "$GITHUB_OUTPUT"
|
||||||
- name: Remove BuildKit image (moby/buildkit)
|
- name: Remove BuildKit image (moby/buildkit)
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
docker image rm -f $(docker images 'moby/buildkit*' -q) 2>/dev/null || true
|
docker image rm -f $(docker images 'moby/buildkit*' -q) 2>/dev/null || true
|
||||||
|
|
||||||
- name: Cleanup (always, scoped)
|
- name: Cleanup (always, scoped)
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: |
|
run: |
|
||||||
@ -231,12 +227,7 @@ jobs:
|
|||||||
publish:
|
publish:
|
||||||
name: Publish Release
|
name: Publish Release
|
||||||
needs: [check-upstream, build-gh, build-self]
|
needs: [check-upstream, build-gh, build-self]
|
||||||
if: |
|
if: needs.check-upstream.outputs.new_version != 'none' && (needs.build-gh.outputs.built == 'true' || needs.build-self.outputs.built == 'true')
|
||||||
${{
|
|
||||||
always() &&
|
|
||||||
needs.check-upstream.outputs.new_version != 'none' &&
|
|
||||||
(needs.build-gh.result == 'success' || needs.build-self.result == 'success')
|
|
||||||
}}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
@ -252,15 +243,3 @@ jobs:
|
|||||||
- docker pull ${{ env.IMAGE_NAME }}:latest
|
- docker pull ${{ env.IMAGE_NAME }}:latest
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|
||||||
finalize:
|
|
||||||
name: Finalize Outcome
|
|
||||||
needs: [check-upstream, build-gh, build-self, publish]
|
|
||||||
if: ${{ always() && needs.check-upstream.outputs.new_version != 'none' }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Fail if no build path succeeded
|
|
||||||
if: ${{ !(needs.build-gh.result == 'success' || needs.build-self.result == 'success') }}
|
|
||||||
run: |
|
|
||||||
echo "Both GitHub-hosted and self-hosted builds failed."
|
|
||||||
exit 1
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user