Skip to content

The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.

CI: publish multi-arch container images to GHCR on release tags (#20)

Tim Gutberlet3cdd949123b7
diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml
new file mode 100644
index 00000000..6ff0316a
--- /dev/null
+++ b/.github/workflows/publish-images.yml
@@ -0,0 +1,168 @@
+# Publish public multi-arch container images to GitHub Container Registry on release tags (v*)
+# or manual dispatch, so Coolify, Dokploy, CapRover and self-hosters can pull prebuilt images
+# instead of building from source.
+#
+# Images are published under the repository-scoped namespace:
+# ghcr.io/linedesk/linedesk/api
+# ghcr.io/linedesk/linedesk/web
+# ghcr.io/linedesk/linedesk/proxy
+# ghcr.io/linedesk/linedesk/agent
+#
+# Keeping the repository prefix (`linedesk/linedesk/<service>`) keeps public self-hosting images
+# separate from the maintainers' staging/production packages (`ghcr.io/linedesk/linedesk-<service>`)
+# and links each package directly to this public repository.
+name: Publish container images
+
+on:
+ push:
+ tags:
+ - "v*"
+ workflow_dispatch:
+ inputs:
+ tag:
+ description: "Release tag to build and publish (e.g. v0.2.15). Leave empty to publish :edge from the selected branch."
+ required: false
+ default: ""
+
+concurrency:
+ group: publish-images-${{ inputs.tag || github.ref }}
+ cancel-in-progress: false
+
+permissions:
+ contents: read
+ packages: write
+
+jobs:
+ build:
+ if: github.repository == 'linedesk/linedesk'
+ strategy:
+ fail-fast: false
+ matrix:
+ service: [api, web, proxy, agent]
+ target:
+ - arch: amd64
+ runner: ubuntu-24.04
+ platform: linux/amd64
+ - arch: arm64
+ runner: ubuntu-24.04-arm
+ platform: linux/arm64
+ runs-on: ${{ matrix.target.runner }}
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
+ with:
+ ref: ${{ inputs.tag || github.ref }}
+ persist-credentials: false
+
+ - name: Record checked-out revision
+ id: rev
+ run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
+
+ - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
+
+ - uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Build and push ${{ matrix.service }} (${{ matrix.target.arch }}) by digest
+ id: build
+ uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
+ with:
+ context: .
+ target: ${{ matrix.service }}
+ platforms: ${{ matrix.target.platform }}
+ provenance: false
+ sbom: false
+ build-args: |
+ SOURCE_DATE_EPOCH=0
+ labels: |
+ org.opencontainers.image.source=https://github.com/linedesk/linedesk
+ org.opencontainers.image.url=https://linedesk.ai
+ org.opencontainers.image.documentation=https://github.com/linedesk/linedesk/blob/main/docs/self-hosting.md
+ org.opencontainers.image.licenses=MIT
+ org.opencontainers.image.title=linedesk-${{ matrix.service }}
+ org.opencontainers.image.description=Linedesk open-source AI receptionist (${{ matrix.service }})
+ org.opencontainers.image.revision=${{ steps.rev.outputs.sha }}
+ outputs: type=image,name=ghcr.io/linedesk/linedesk/${{ matrix.service }},push-by-digest=true,name-canonical=true,push=true
+ cache-from: type=gha,scope=${{ matrix.service }}-${{ matrix.target.arch }}
+ cache-to: type=gha,mode=max,scope=${{ matrix.service }}-${{ matrix.target.arch }}
+
+ - name: Record digest
+ env:
+ DIGEST: ${{ steps.build.outputs.digest }}
+ ARCH: ${{ matrix.target.arch }}
+ run: |
+ mkdir -p /tmp/digests
+ printf '%s\n' "$DIGEST" > "/tmp/digests/${ARCH}"
+
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: digest-${{ matrix.service }}-${{ matrix.target.arch }}
+ path: /tmp/digests/${{ matrix.target.arch }}
+ retention-days: 1
+
+ merge:
+ if: github.repository == 'linedesk/linedesk'
+ needs: [build]
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ strategy:
+ fail-fast: false
+ matrix:
+ service: [api, web, proxy, agent]
+ steps:
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ pattern: digest-${{ matrix.service }}-*
+ path: /tmp/digests
+ merge-multiple: true
+
+ - uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Create multi-arch manifest list for ${{ matrix.service }}
+ env:
+ SERVICE: ${{ matrix.service }}
+ INPUT_TAG: ${{ inputs.tag }}
+ EVENT_NAME: ${{ github.event_name }}
+ REF_NAME: ${{ github.ref_name }}
+ run: |
+ set -euo pipefail
+ IMAGE="ghcr.io/linedesk/linedesk/${SERVICE}"
+ AMD64_DIGEST=$(tr -d '[:space:]' < /tmp/digests/amd64)
+ ARM64_DIGEST=$(tr -d '[:space:]' < /tmp/digests/arm64)
+
+ if [ "$EVENT_NAME" = "push" ]; then
+ TAG="$REF_NAME"
+ else
+ TAG="$INPUT_TAG"
+ fi
+
+ TAGS=()
+ if [ -n "$TAG" ]; then
+ if ! printf '%s' "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
+ echo "Invalid release tag: $TAG (expected vX.Y.Z)" >&2
+ exit 1
+ fi
+ SEMVER="${TAG#v}"
+ TAGS+=(--tag "${IMAGE}:${TAG}" --tag "${IMAGE}:${SEMVER}")
+ # Stable releases (no pre-release suffix) also move minor (X.Y) and :latest.
+ if ! printf '%s' "$SEMVER" | grep -q '-'; then
+ MINOR=$(printf '%s' "$SEMVER" | awk -F. '{print $1 "." $2}')
+ TAGS+=(--tag "${IMAGE}:${MINOR}" --tag "${IMAGE}:latest")
+ fi
+ else
+ TAGS+=(--tag "${IMAGE}:edge")
+ fi
+
+ docker buildx imagetools create \
+ "${TAGS[@]}" \
+ "${IMAGE}@${AMD64_DIGEST}" \
+ "${IMAGE}@${ARM64_DIGEST}"
+
+ docker buildx imagetools inspect "${IMAGE}:${TAG:-edge}"