Skip to content

ci: build + publish example container images (hello-world, echo, tiles) #1

ci: build + publish example container images (hello-world, echo, tiles)

ci: build + publish example container images (hello-world, echo, tiles) #1

Workflow file for this run

name: Build example images
# Build every containerized example and push to Docker Hub as
# livepeer/sample-<example>. Runs on main, on manual dispatch, and on v*
# tags (a v* tag versions the whole example suite together).
#
# Add a new example: give it a Dockerfile whose build context is its own
# directory, then add its folder name to the matrix below.
on:
push:
branches: [main]
tags:
- "v*"
paths:
- "hello-world/**"
- "echo/**"
- "tiles/**"
- ".github/workflows/images.yml"
pull_request:
paths:
- "hello-world/**"
- "echo/**"
- "tiles/**"
- ".github/workflows/images.yml"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
images:
name: ${{ matrix.example }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
example: [hello-world, echo, tiles]
steps:
- uses: actions/checkout@v4
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: livepeer/sample-${{ 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') && github.event.base_ref == 'refs/heads/main' }}
labels: |
org.opencontainers.image.title=sample-${{ matrix.example }}
org.opencontainers.image.description=Livepeer sample app (${{ matrix.example }}) — example, not production-ready
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
# Push on main/tags and on team (same-repo) PRs. Fork PRs can't access
# secrets, so they build-only to validate the Dockerfile.
- name: Log in to Docker Hub
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: docker/login-action@v3
with:
username: ${{ secrets.CI_DOCKERHUB_USERNAME }}
password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.example }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
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 }}