45 lines
1.2 KiB
YAML
45 lines
1.2 KiB
YAML
name: Docker Build and Push
|
|
description: Build, test, tag, and optionally push the Hamkar image
|
|
inputs:
|
|
image:
|
|
description: Full OCI image name without a tag
|
|
required: true
|
|
branch:
|
|
description: Human-readable image tag
|
|
required: true
|
|
commit_sha:
|
|
description: Immutable commit image tag
|
|
required: true
|
|
push:
|
|
description: Push both tags to the registry
|
|
required: false
|
|
default: "true"
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Build image
|
|
shell: bash
|
|
env:
|
|
IMAGE: ${{ inputs.image }}
|
|
BRANCH: ${{ inputs.branch }}
|
|
COMMIT_SHA: ${{ inputs.commit_sha }}
|
|
PUSH_IMAGE: ${{ inputs.push }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
go_proxy="${GOPROXY:-https://proxy.golang.org/}"
|
|
output=(--load)
|
|
if [[ "$PUSH_IMAGE" == "true" ]]; then
|
|
output=(--push)
|
|
fi
|
|
|
|
docker buildx build \
|
|
-f build/dockerfile \
|
|
--build-arg "GO_PROXY=$go_proxy" \
|
|
--label "org.opencontainers.image.revision=$COMMIT_SHA" \
|
|
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL:-}" \
|
|
"${output[@]}" \
|
|
-t "$IMAGE:$BRANCH" \
|
|
-t "$IMAGE:$COMMIT_SHA" \
|
|
.
|