| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- name: docker
- # Docker image pipeline (optional install path, docs/docker.md).
- # - pull_request: builds the server image on amd64 to keep the Dockerfile
- # honest; publishes nothing.
- # - v* tag: builds linux/amd64 + linux/arm64 and pushes to GHCR, tagged
- # semver + latest. The workflow is identical on forks and upstream:
- # images land under ghcr.io/<owner>/<repo> from github.repository, and
- # the built-in GITHUB_TOKEN is enough (no registry secrets).
- on:
- pull_request:
- paths:
- - 'Dockerfile'
- - '.dockerignore'
- - 'docker-compose.yml'
- - 'scripts/build-agents.sh'
- - '.github/workflows/docker.yml'
- push:
- tags: ['v*']
- concurrency:
- group: docker-${{ github.event.pull_request.number || github.ref }}
- cancel-in-progress: true
- permissions:
- contents: read
- packages: write
- env:
- REGISTRY: ghcr.io
- jobs:
- image:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- - uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
- - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- # Image name lowercased (GHCR rejects uppercase), version from the tag
- # minus the v prefix (same value goreleaser feeds httpapi.Version), and
- # the agent version from agent/VERSION (#790) so the embed stamp
- # matches the release binaries.
- - name: Resolve image, version and agent version
- id: meta
- env:
- REPO: ${{ github.repository }}
- run: |
- set -e
- IMAGE="$REGISTRY/$(echo "$REPO" | tr '[:upper:]' '[:lower:]')"
- echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
- echo "agent=$(tr -d '[:space:]' < agent/VERSION)" >> "$GITHUB_OUTPUT"
- echo "commit=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
- if [ "${{ github.ref_type }}" = 'tag' ]; then
- VERSION="${GITHUB_REF_NAME#v}"
- echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- echo "platforms=linux/amd64,linux/arm64" >> "$GITHUB_OUTPUT"
- echo "push=true" >> "$GITHUB_OUTPUT"
- MAJMIN="${VERSION%.*}"
- MAJ="${VERSION%%.*}"
- {
- echo "tags<<EOF"
- echo "$IMAGE:$VERSION"
- echo "$IMAGE:$MAJMIN"
- echo "$IMAGE:$MAJ"
- echo "$IMAGE:latest"
- echo "EOF"
- } >> "$GITHUB_OUTPUT"
- else
- echo "version=0.0.0-pr" >> "$GITHUB_OUTPUT"
- echo "platforms=linux/amd64" >> "$GITHUB_OUTPUT"
- echo "push=false" >> "$GITHUB_OUTPUT"
- echo "tags=$IMAGE:pr-validation" >> "$GITHUB_OUTPUT"
- fi
- - name: Log in to GHCR (tag builds only)
- if: github.ref_type == 'tag'
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- - uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
- with:
- context: .
- platforms: ${{ steps.meta.outputs.platforms }}
- push: ${{ steps.meta.outputs.push }}
- tags: ${{ steps.meta.outputs.tags }}
- build-args: |
- VERSION=${{ steps.meta.outputs.version }}
- BUILD_COMMIT=${{ steps.meta.outputs.commit }}
- AGENT_VERSION=${{ steps.meta.outputs.agent }}
- cache-from: type=gha
- cache-to: type=gha,mode=max
|