From c418290dbf55086f928a7a941e11bfa13cff8eb2 Mon Sep 17 00:00:00 2001 From: Bryan Seitz <171158+seitzbg@users.noreply.github.com> Date: Wed, 3 Jun 2026 19:07:42 -0400 Subject: [PATCH] ci: build and publish Docker image to GHCR Add a GitHub Actions workflow that builds the Docker image on every pull request (build-only, no push, so fork PRs need no secrets) and publishes to ghcr.io//slopsoil on pushes to main and on v*.*.* release tags. Tags: main -> :latest, :sha- (:latest tracks main HEAD) v1.2.3 -> :stable, :1.2.3, :1.2 (:stable tracks newest release) Uses the built-in GITHUB_TOKEN (no extra secrets to configure), linux/amd64 only to match the VA-API hardware-accel Dockerfile, with GitHub Actions layer caching. --- .github/workflows/docker-publish.yml | 68 ++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..8e5e92b --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,68 @@ +name: Build and Publish Docker Image + +on: + pull_request: + push: + branches: [main] + tags: ["v*.*.*"] + +concurrency: + group: docker-publish-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Buildx + uses: docker/setup-buildx-action@v3 + + # Only log in when we're actually going to push. Pull requests (including + # those from forks) build the image to validate the Dockerfile but never + # push, so they need no registry credentials or secrets. + - name: Log in to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Tagging scheme: + # push to main -> :latest, :sha- + # tag v1.2.3 -> :stable, :1.2.3, :1.2 + # pull request -> (none; build only) + # :latest tracks main HEAD; :stable tracks the newest release tag. + - name: Compute tags and labels + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + flavor: | + latest=false + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=sha,prefix=sha-,enable={{is_default_branch}} + type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # Read the layer cache on every run; only write it when pushing, since + # fork pull requests can't write to the Actions cache. + cache-from: type=gha + cache-to: ${{ github.event_name != 'pull_request' && 'type=gha,mode=max' || '' }}