|
| 1 | +name: Build ai-runner live pipeline Docker images |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - "runner/docker/Dockerfile.live-*" |
| 7 | + - "runner/app/**" |
| 8 | + - "runner/images/**" |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + tags: |
| 13 | + - '*' |
| 14 | + paths: |
| 15 | + - "runner/docker/Dockerfile.live-*" |
| 16 | + - "runner/app/**" |
| 17 | + - "runner/images/**" |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + build-common-base: |
| 26 | + name: Build common live base image |
| 27 | + permissions: |
| 28 | + pull-requests: read |
| 29 | + runs-on: ubuntu-20.04 |
| 30 | + steps: |
| 31 | + - name: Check out code |
| 32 | + |
| 33 | + with: |
| 34 | + fetch-depth: 50 |
| 35 | + ref: ${{ github.event.pull_request.head.sha }} |
| 36 | + |
| 37 | + - name: Get changed files |
| 38 | + id: changed-files |
| 39 | + uses: tj-actions/changed-files@v45 |
| 40 | + with: |
| 41 | + files: | |
| 42 | + runner/docker/Dockerfile.live-base |
| 43 | +
|
| 44 | + - name: Check if build needed |
| 45 | + id: check_build |
| 46 | + if: | |
| 47 | + github.event_name == 'workflow_dispatch' || |
| 48 | + github.event_name == 'push' || |
| 49 | + ( |
| 50 | + github.event_name == 'pull_request' && |
| 51 | + github.event.pull_request.head.repo.full_name == github.repository && |
| 52 | + steps.changed-files.outputs.any_changed == 'true' |
| 53 | + ) |
| 54 | + run: echo "should_build=true" >> $GITHUB_OUTPUT |
| 55 | + |
| 56 | + - name: Cleanup hosted runner |
| 57 | + uses: ./.github/actions/cleanup-runner |
| 58 | + if: steps.check_build.outputs.should_build == 'true' |
| 59 | + |
| 60 | + - name: Set up Docker Buildx |
| 61 | + uses: docker/setup-buildx-action@v3 |
| 62 | + |
| 63 | + - name: Login to DockerHub |
| 64 | + uses: docker/login-action@v3 |
| 65 | + with: |
| 66 | + username: ${{ secrets.CI_DOCKERHUB_USERNAME }} |
| 67 | + password: ${{ secrets.CI_DOCKERHUB_TOKEN }} |
| 68 | + |
| 69 | + - name: Build and push live-base image |
| 70 | + uses: docker/build-push-action@v5 |
| 71 | + if: steps.check_build.outputs.should_build == 'true' |
| 72 | + with: |
| 73 | + context: "{{defaultContext}}:runner" |
| 74 | + platforms: linux/amd64 |
| 75 | + push: ${{ github.event_name != 'pull_request' }} |
| 76 | + tags: livepeer/ai-runner:live-base |
| 77 | + file: docker/Dockerfile.live-base |
| 78 | + cache-from: type=registry,ref=livepeerci/build:cache |
| 79 | + cache-to: type=registry,ref=livepeerci/build:cache,mode=max |
| 80 | + |
| 81 | + build-pipeline-images: |
| 82 | + name: Build pipeline images |
| 83 | + needs: build-common-base |
| 84 | + runs-on: ubuntu-20.04 |
| 85 | + permissions: |
| 86 | + pull-requests: read |
| 87 | + strategy: |
| 88 | + matrix: |
| 89 | + pipeline: [streamdiffusion, comfyui, liveportrait] |
| 90 | + fail-fast: false |
| 91 | + steps: |
| 92 | + - name: Check out code |
| 93 | + |
| 94 | + with: |
| 95 | + fetch-depth: 50 |
| 96 | + ref: ${{ github.event.pull_request.head.sha }} |
| 97 | + |
| 98 | + - name: Get changed files |
| 99 | + id: changed-files |
| 100 | + uses: tj-actions/changed-files@v45 |
| 101 | + with: |
| 102 | + files_yaml: | |
| 103 | + base_dockerfile: |
| 104 | + - runner/docker/Dockerfile.live-base-${{ matrix.pipeline }} |
| 105 | + liveportrait: |
| 106 | + - runner/images/** |
| 107 | + - runner/requirements-liveportrait.txt |
| 108 | +
|
| 109 | + - name: Cleanup hosted runner |
| 110 | + uses: ./.github/actions/cleanup-runner |
| 111 | + |
| 112 | + - name: Set up Docker Buildx |
| 113 | + uses: docker/setup-buildx-action@v3 |
| 114 | + |
| 115 | + - name: Login to DockerHub |
| 116 | + uses: docker/login-action@v3 |
| 117 | + with: |
| 118 | + username: ${{ secrets.CI_DOCKERHUB_USERNAME }} |
| 119 | + password: ${{ secrets.CI_DOCKERHUB_TOKEN }} |
| 120 | + |
| 121 | + - name: Build and push pipeline base image |
| 122 | + uses: docker/build-push-action@v5 |
| 123 | + if: | |
| 124 | + github.event_name == 'workflow_dispatch' || |
| 125 | + github.event_name == 'push' || |
| 126 | + ( |
| 127 | + github.event_name == 'pull_request' && |
| 128 | + github.event.pull_request.head.repo.full_name == github.repository && |
| 129 | + ( |
| 130 | + steps.changed-files.outputs.base_dockerfile_any_changed == 'true' || |
| 131 | + ( |
| 132 | + matrix.pipeline == 'liveportrait' && |
| 133 | + steps.changed-files.outputs.liveportrait_any_changed == 'true' |
| 134 | + ) |
| 135 | + ) |
| 136 | + ) |
| 137 | + with: |
| 138 | + context: "{{defaultContext}}:runner" |
| 139 | + platforms: linux/amd64 |
| 140 | + push: ${{ github.event_name != 'pull_request' }} |
| 141 | + tags: livepeer/ai-runner:live-base-${{ matrix.pipeline }} |
| 142 | + file: docker/Dockerfile.live-base-${{ matrix.pipeline }} |
| 143 | + build-args: | |
| 144 | + PIPELINE=${{ matrix.pipeline }} |
| 145 | + cache-from: type=registry,ref=livepeerci/build:cache |
| 146 | + cache-to: type=registry,ref=livepeerci/build:cache,mode=max |
| 147 | + |
| 148 | + - name: Extract metadata for app image |
| 149 | + id: meta |
| 150 | + uses: docker/metadata-action@v5 |
| 151 | + with: |
| 152 | + images: livepeer/ai-runner |
| 153 | + tags: | |
| 154 | + type=raw,value=live-app-${{ matrix.pipeline }} |
| 155 | + type=sha,prefix=live-app-${{ matrix.pipeline }}- |
| 156 | + type=ref,event=pr,prefix=live-app-${{ matrix.pipeline }}- |
| 157 | + type=ref,event=tag,prefix=live-app-${{ matrix.pipeline }}- |
| 158 | + type=raw,value=latest,enable={{is_default_branch}},prefix=live-app-${{ matrix.pipeline }}- |
| 159 | +
|
| 160 | + - name: Build and push pipeline app image |
| 161 | + uses: docker/build-push-action@v5 |
| 162 | + with: |
| 163 | + context: "{{defaultContext}}:runner" |
| 164 | + platforms: linux/amd64 |
| 165 | + push: ${{ github.event_name != 'pull_request' }} |
| 166 | + tags: ${{ steps.meta.outputs.tags }} |
| 167 | + file: docker/Dockerfile.live-app__PIPELINE__ |
| 168 | + build-args: | |
| 169 | + PIPELINE=${{ matrix.pipeline }} |
| 170 | + cache-from: type=registry,ref=livepeerci/build:cache |
| 171 | + cache-to: type=registry,ref=livepeerci/build:cache,mode=max |
| 172 | + |
| 173 | + build-noop: |
| 174 | + name: Build pipeline image (noop) |
| 175 | + needs: build-common-base |
| 176 | + runs-on: ubuntu-20.04 |
| 177 | + permissions: |
| 178 | + pull-requests: read |
| 179 | + steps: |
| 180 | + - name: Check out code |
| 181 | + |
| 182 | + with: |
| 183 | + fetch-depth: 50 |
| 184 | + ref: ${{ github.event.pull_request.head.sha }} |
| 185 | + |
| 186 | + - name: Get changed files |
| 187 | + id: changed-files |
| 188 | + uses: tj-actions/changed-files@v45 |
| 189 | + with: |
| 190 | + files: | |
| 191 | + runner/docker/Dockerfile.live-app-noop |
| 192 | + runner/app/** |
| 193 | +
|
| 194 | + - name: Check if build needed |
| 195 | + id: check_build |
| 196 | + if: | |
| 197 | + github.event_name == 'workflow_dispatch' || |
| 198 | + github.event_name == 'push' || |
| 199 | + ( |
| 200 | + github.event_name == 'pull_request' && |
| 201 | + github.event.pull_request.head.repo.full_name == github.repository && |
| 202 | + steps.changed-files.outputs.any_changed == 'true' |
| 203 | + ) |
| 204 | + run: echo "should_build=true" >> $GITHUB_OUTPUT |
| 205 | + |
| 206 | + - name: Cleanup hosted runner |
| 207 | + uses: ./.github/actions/cleanup-runner |
| 208 | + if: steps.check_build.outputs.should_build == 'true' |
| 209 | + |
| 210 | + - name: Set up Docker Buildx |
| 211 | + uses: docker/setup-buildx-action@v3 |
| 212 | + |
| 213 | + - name: Login to DockerHub |
| 214 | + uses: docker/login-action@v3 |
| 215 | + with: |
| 216 | + username: ${{ secrets.CI_DOCKERHUB_USERNAME }} |
| 217 | + password: ${{ secrets.CI_DOCKERHUB_TOKEN }} |
| 218 | + |
| 219 | + - name: Extract metadata for Docker |
| 220 | + id: meta |
| 221 | + uses: docker/metadata-action@v5 |
| 222 | + with: |
| 223 | + images: livepeer/ai-runner |
| 224 | + tags: | |
| 225 | + type=raw,value=live-app-noop |
| 226 | + type=sha,prefix=live-app-noop- |
| 227 | + type=ref,event=pr,prefix=live-app-noop- |
| 228 | + type=ref,event=tag,prefix=live-app-noop- |
| 229 | + type=raw,value=latest,enable={{is_default_branch}},prefix=live-app-noop- |
| 230 | +
|
| 231 | + - name: Build and push noop image |
| 232 | + uses: docker/build-push-action@v5 |
| 233 | + if: steps.check_build.outputs.should_build == 'true' |
| 234 | + with: |
| 235 | + context: "{{defaultContext}}:runner" |
| 236 | + platforms: linux/amd64 |
| 237 | + push: ${{ github.event_name != 'pull_request' }} |
| 238 | + tags: ${{ steps.meta.outputs.tags }} |
| 239 | + file: docker/Dockerfile.live-app-noop |
| 240 | + cache-from: type=registry,ref=livepeerci/build:cache |
| 241 | + cache-to: type=registry,ref=livepeerci/build:cache,mode=max |
0 commit comments