name: docker-control # Builds the control-layer image (the `handler` CLI / CI poller) from Dockerfile.control # and publishes it to GHCR alongside the API image built by docker.yml. on: push: branches: [main] tags: ["v*"] pull_request: branches: [main] env: IMAGE: ghcr.io/${{ github.repository }}/control jobs: build: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - 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 }} # Tags: branch name on branch pushes, semver on v* tags, short SHA always, # `latest` only on the default branch. metadata-action lowercases the repo # name (GHCR requires lowercase). - name: Docker metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE }} tags: | type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=sha type=raw,value=latest,enable={{is_default_branch}} - name: Build and push uses: docker/build-push-action@v6 with: context: . file: Dockerfile.control platforms: linux/amd64,linux/arm64 # PRs build (to catch Dockerfile breakage) but never push. push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha,scope=control cache-to: type=gha,mode=max,scope=control