60 lines
2.3 KiB
YAML
60 lines
2.3 KiB
YAML
name: containerd-build
|
|
description: Pushes a containerd image.
|
|
inputs:
|
|
registry_host:
|
|
description: A containerd registry host.
|
|
required: false
|
|
default: ${{ vars.INTELIGR8_REGISTRY_HOST }}
|
|
image_namespace:
|
|
description: A containerd image prefix.
|
|
required: false
|
|
default: ${{ vars.INTELIGR8_IMAGE_NAMESPACE }}
|
|
image_name:
|
|
description: A containerd image name, without the host and prefix.
|
|
required: true
|
|
target_image_tag:
|
|
description: A new tag for the specified containerd image.
|
|
required: false
|
|
push_opts:
|
|
description: A string of options for the containerd CLI build command.
|
|
required: false
|
|
default: --quiet
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- id: containerd_debug
|
|
uses: ./.gitea/actions/containerd-debug
|
|
- id: containerd_push
|
|
working-directory: containerd
|
|
env:
|
|
REGISTRY_HOST: ${{ inputs.registry_host }}
|
|
IMAGE_NAMESPACE: ${{ inputs.image_namespace }}
|
|
IMAGE_NAME: ${{ inputs.image_name }}
|
|
TARGET_IMAGE_TAG: ${{ inputs.target_image_tag }}
|
|
CONTAINERD_CMD: buildah
|
|
CONTAINERD_PUSH_OPTS: ${{ inputs.push_opts }}
|
|
CONTAINERD_CMD_DEBUG_OPTS: ${{ steps.containerd_debug.outputs.containerd_cmd_debug_opts }}
|
|
shell: bash
|
|
run: |
|
|
IMAGE_REMOTE_NAME=${REGISTRY_HOST}/${IMAGE_NAMESPACE}${IMAGE_NAME}
|
|
|
|
if [[ -z ${TARGET_IMAGE_TAG} ]]; then
|
|
GIT_COMMIT_SHORT_SHA=${GITHUB_SHA::8}
|
|
echo "Pushing container image to registry with commit SHA: ${GIT_COMMIT_SHORT_SHA}"
|
|
TARGET_IMAGE_TAG=sha${GIT_COMMIT_SHORT_SHA}
|
|
else
|
|
SOURCE_IMAGE_TAG=sha${GIT_COMMIT_SHORT_SHA}
|
|
echo "Synchronizing container image from registry for tag: ${SOURCE_IMAGE_TAG}"
|
|
${CONTAINERD_CMD} ${CONTAINERD_CMD_OPTS} pull \
|
|
${CONTAINERD_IMAGE_REMOTE_NAME}:${SOURCE_IMAGE_TAG}
|
|
|
|
echo "Tagging container image to registry with version: ${TARGET_IMAGE_TAG}"
|
|
${CONTAINERD_CMD} ${CONTAINERD_CMD_OPTS} ${CONTAINERD_CMD_DEBUG_OPTS} tag \
|
|
${CONTAINERD_IMAGE_REMOTE_NAME}:${SOURCE_IMAGE_TAG} \
|
|
${CONTAINERD_IMAGE_REMOTE_NAME}:${TARGET_IMAGE_TAG}
|
|
fi
|
|
|
|
${CONTAINERD_CMD} ${CONTAINERD_CMD_OPTS} ${CONTAINERD_CMD_DEBUG_OPTS} push \
|
|
${CONTAINERD_PUSH_OPTS} \
|
|
${IMAGE_REMOTE_NAME}:${TARGET_IMAGE_TAG}
|