ci: publish the example images to ghcr and make them runnable #135
Workflow file for this run
This file contains hidden or 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 example runner images | |
| # This repo ships EXAMPLE runners: images publish to the GitHub Container Registry | |
| # as ghcr.io/<owner>/runner-example-<name>. Production runners drop "example" | |
| # (runner-<name>). | |
| # | |
| # GHCR needs no stored credentials: the built-in GITHUB_TOKEN publishes, and the | |
| # packages are public, so pulling needs none either. Docker Hub is deliberately not | |
| # a second target — see "Images" in the README. | |
| # | |
| # Runs on main / v* tags / manual dispatch; PRs build only (workflow_dispatch to | |
| # pull-test a branch). amd64 only (Livepeer GPU work is NVIDIA/amd64; no CUDA on | |
| # arm64/Mac). Add an example: add its folder (with a Dockerfile) to the matrix + | |
| # paths below. | |
| on: | |
| push: | |
| branches: [main] | |
| tags: | |
| - "v*" | |
| paths: &image_paths | |
| - "hello-world/**" | |
| - "echo/**" | |
| - "tiles/**" | |
| - "realtime-transcription/**" | |
| - ".github/workflows/images.yml" | |
| pull_request: | |
| paths: *image_paths | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| images: | |
| name: ${{ matrix.example }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write # publishing to ghcr.io | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| example: [hello-world, echo, tiles, realtime-transcription] | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| # Owner comes from the repo, so a fork publishes under its own namespace. | |
| images: ghcr.io/${{ github.repository_owner }}/runner-example-${{ matrix.example }} | |
| tags: | | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=sha,format=short | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
| labels: | | |
| org.opencontainers.image.title=runner-example-${{ matrix.example }} | |
| org.opencontainers.image.description=Livepeer runner example (${{ matrix.example }}) — example, not production-ready | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| # Allowlist push + dispatch — any other event (PRs, incl. pull_request_target) | |
| # is build-only and never gets a package-writing token. | |
| - name: Log in to GHCR | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: ./${{ matrix.example }} | |
| platforms: linux/amd64 | |
| push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=${{ matrix.example }} | |
| cache-to: type=gha,mode=max,scope=${{ matrix.example }} |