Skip to content

Deploy — Docker

Builds a multi-platform Docker image and pushes it to GitHub Container Registry (GHCR).

Usage

yaml
jobs:
  docker:
    uses: KevinDeBenedetti/github-workflows/.github/workflows/cd-docker.yml@main
    with:
      image-name: my-api
      platforms: linux/amd64,linux/arm64

Inputs

InputTypeDefaultDescription
image-namestring''Image name (e.g. my-api). Defaults to the repository name.
contextstring'.'Docker build context (e.g. apps/api)
dockerfilestringDockerfilePath to the Dockerfile, relative to context
platformsstringlinux/amd64,linux/arm64Comma-separated target platforms
pushbooleantruePush image to GHCR
targetstring''Build target stage (e.g. dev, prod)
tag-latestbooleanfalseAlso tag the image as :latest on the default branch
versionstring''Explicit version tag to apply (e.g. v1.2.3). When set, adds a type=raw tag with this value.
build-argsstring''List of Docker build-args (one per line, KEY=VALUE)

Outputs

OutputDescription
imageImage tag(s) applied to the build (newline-separated)
digestImage digest

Tags applied

EventTag
Branch push<branch-name>
Pull requestpr-<number>
Semver tag<version>, <major>.<minor>
Any commitsha-<short-sha>
Default branch + tag-latest: truelatest

Notes

  • Uses docker/metadata-action for automatic tag and label generation.
  • Build cache is scoped per context using GitHub Actions cache (type=gha).
  • The job runs in the production environment on main, otherwise preview.
  • Requires packages: write permission (granted automatically via GITHUB_TOKEN).