From 12a3ec5eaf0a641df2059dfcef41b2b75d920c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E9=88=9E?= Date: Tue, 12 Mar 2024 22:51:50 +0800 Subject: [PATCH] feat: add CI for forge branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陳鈞 --- .github/workflows/docker_publish.yml | 95 ++++++++++++++++++++++++---- docker-compose.yml | 1 + 2 files changed, 85 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker_publish.yml b/.github/workflows/docker_publish.yml index e2638b8..d0609a5 100644 --- a/.github/workflows/docker_publish.yml +++ b/.github/workflows/docker_publish.yml @@ -12,8 +12,9 @@ on: workflow_dispatch: jobs: - docker: + docker-tag: runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') steps: - name: Checkout @@ -24,15 +25,8 @@ jobs: - name: Checkout submodule run: | cd stable-diffusion-webui && \ - if [[ "${{ github.ref }}" == refs/tags/* ]]; then - git fetch --all --tags && \ - git checkout tags/${{ github.ref_name }} -b ${{ github.ref_name }} - echo "VERSION=${{ github.ref_name }}" >> "$GITHUB_ENV" - else - git fetch origin +refs/heads/*:refs/remotes/origin/* -v && \ - git checkout -b dev origin/dev; - echo "VERSION=dev" >> "$GITHUB_ENV"; - fi + git fetch --all --tags && \ + git checkout tags/${{ github.ref_name }} -b ${{ github.ref_name }} - name: Setup docker id: setup @@ -51,7 +45,86 @@ jobs: tags: ${{ steps.setup.outputs.tags }} labels: ${{ steps.setup.outputs.labels }} build-args: | - VERSION=${{ env.VERSION }} + VERSION=${{ github.ref_name }} + RELEASE=${{ github.run_number }} + platforms: linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + + docker-dev: + runs-on: ubuntu-latest + if: (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master')) + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Checkout submodule + run: | + cd stable-diffusion-webui && \ + git fetch origin +refs/heads/*:refs/remotes/origin/* -v && \ + git checkout -b dev origin/dev; + + - name: Setup docker + id: setup + uses: ./.github/workflows/docker-reused-setup-steps + with: + CR_PAT: ${{ secrets.CR_PAT }} + tag: ${{ github.head_ref || github.ref_name }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + target: final + tags: ${{ steps.setup.outputs.tags }} + labels: ${{ steps.setup.outputs.labels }} + build-args: | + VERSION=dev + RELEASE=${{ github.run_number }} + platforms: linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + + docker-forge: + runs-on: ubuntu-latest + if: (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master')) + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Checkout submodule + run: | + cd stable-diffusion-webui && \ + git remote add forge https://github.com/lllyasviel/stable-diffusion-webui-forge && \ + git fetch forge +refs/heads/*:refs/remotes/forge/* -v && \ + git checkout -b main forge/main; + + - name: Setup docker + id: setup + uses: ./.github/workflows/docker-reused-setup-steps + with: + CR_PAT: ${{ secrets.CR_PAT }} + tag: ${{ github.head_ref || github.ref_name }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + target: final + tags: ${{ steps.setup.outputs.tags }} + labels: ${{ steps.setup.outputs.labels }} + build-args: | + VERSION=forge RELEASE=${{ github.run_number }} platforms: linux/amd64 cache-from: type=gha diff --git a/docker-compose.yml b/docker-compose.yml index ac2b5c2..73f6c66 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: "3.9" services: stable-diffusion-webui: container_name: stable-diffusion-webui + # image: ghcr.io/jim60105/stable-diffusion-webui:forge image: ghcr.io/jim60105/stable-diffusion-webui:v1.8.0 # build: . user: "1001:0"