Build and push images for stable diffusion use-case #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push images for stable diffusion use-case | |
on: | |
workflow_dispatch: | |
inputs: | |
imageTag: | |
description: "container image tag" | |
required: false | |
default: latest | |
type: string | |
skipWorker: | |
description: "should the build for worker image be skipped" | |
required: false | |
default: 'true' | |
type: string | |
workflow_call: | |
inputs: | |
imageTag: | |
description: "container image tag" | |
required: false | |
default: latest | |
type: string | |
skipWorker: | |
description: "should the build for worker image be skipped" | |
required: false | |
default: 'true' | |
type: string | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
CONTAINER_IMG_REGISTRY: ghcr.io | |
CONTAINER_IMG_ORG: kedify | |
CONTAINER_IMG_WORKER_NAME: stable-diffusion-worker | |
CONTAINER_IMG_WEBUI_NAME: stable-diffusion-webui | |
CONTAINER_IMG_TAG: ${{ inputs.imageTag || 'latest' }} | |
jobs: | |
build-container: | |
permissions: | |
contents: write | |
packages: write # push images | |
id-token: write # needed for signing the images with GitHub OIDC Token | |
name: build container | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
makefileTarget: [build-webui-image-multiarch, build-stable-diff-image-multiarch] | |
steps: | |
- name: Maximize build space | |
uses: easimon/maximize-build-space@master | |
if: matrix.makefileTarget == 'build-stable-diff-image-multiarch' && inputs.skipWorker != 'true' | |
with: | |
overprovision-lvm: 'true' | |
remove-dotnet: 'true' | |
remove-android: 'true' | |
remove-haskell: 'true' | |
remove-codeql: 'true' | |
remove-docker-images: 'true' | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
if: matrix.makefileTarget != 'build-stable-diff-image-multiarch' || inputs.skipWorker != 'true' | |
- name: Login to ghcr.io | |
uses: docker/login-action@v3 | |
if: matrix.makefileTarget != 'build-stable-diff-image-multiarch' || inputs.skipWorker != 'true' | |
with: | |
registry: ghcr.io | |
username: kedify | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
if: matrix.makefileTarget != 'build-stable-diff-image-multiarch' || inputs.skipWorker != 'true' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
if: matrix.makefileTarget != 'build-stable-diff-image-multiarch' || inputs.skipWorker != 'true' | |
- name: Build and push | |
env: | |
WORKER_IMAGE: "${{ env.CONTAINER_IMG_REGISTRY }}/${{ env.CONTAINER_IMG_ORG }}/${{ env.CONTAINER_IMG_WORKER_NAME }}:${{ env.CONTAINER_IMG_TAG }}" | |
WEBUI_IMAGE: "${{ env.CONTAINER_IMG_REGISTRY }}/${{ env.CONTAINER_IMG_ORG }}/${{ env.CONTAINER_IMG_WEBUI_NAME }}:${{ env.CONTAINER_IMG_TAG }}" | |
if: matrix.makefileTarget != 'build-stable-diff-image-multiarch' || inputs.skipWorker != 'true' | |
run: | | |
cd samples/stable-diffusion/ | |
make ${{ matrix.makefileTarget }} |