80 lines
2.1 KiB
YAML
80 lines
2.1 KiB
YAML
name: BuildKit Build and Deploys
|
|
description: "Build and deploy images"
|
|
|
|
inputs:
|
|
registry_addr:
|
|
description: registry address
|
|
required: true
|
|
registry_username:
|
|
description: "registry username"
|
|
required: true
|
|
registry_password:
|
|
description: "registry password"
|
|
required: true
|
|
buildkit_addr:
|
|
description: "buildkit address"
|
|
required: true
|
|
tags:
|
|
description: "image tags / buildctl image name"
|
|
required: true
|
|
context:
|
|
description: "buildctl build context"
|
|
required: false
|
|
default: "."
|
|
dockerfile:
|
|
description: "buildctl build dockerfile/folder"
|
|
required: true
|
|
default: "."
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Authenticate to Gitea registry
|
|
shell: bash
|
|
run: |
|
|
|
|
DOCKER_CONFIG_DIR="${RUNNER_TEMP}/.buildctl_docker"
|
|
mkdir -p "$DOCKER_CONFIG_DIR"
|
|
|
|
# clean up
|
|
trap 'rm -rf "$DOCKER_CONFIG_DIR"' EXIT
|
|
|
|
AUTH=$(printf "%s" "${{ inputs.registry_username }}:${{ inputs.registry_password }}" | base64 -w 0)
|
|
|
|
cat > "$DOCKER_CONFIG_DIR/config.json" <<EOF
|
|
{
|
|
"auths": {
|
|
"${{ inputs.registry_addr }}": {
|
|
"auth": "$AUTH"
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
echo "Checking config.json (safe output):"
|
|
if [ ! -f "$DOCKER_CONFIG_DIR/config.json" ]; then
|
|
echo "ERROR: config.json missing"
|
|
exit 1
|
|
fi
|
|
|
|
jq '
|
|
.auths |= with_entries(
|
|
.value.auth = "***MASKED***"
|
|
)
|
|
' "$DOCKER_CONFIG_DIR/config.json"
|
|
|
|
DECODED_USER=$(printf "%s" "$AUTH" | base64 -d | cut -d: -f1)
|
|
echo "Registry user: $DECODED_USER"
|
|
|
|
|
|
# Run BuildKit build
|
|
buildctl \
|
|
--addr ${{ inputs.buildkit_addr }} \
|
|
build \
|
|
--frontend=dockerfile.v0 \
|
|
--local context=${{ inputs.context }} \
|
|
--local dockerfile=${{ inputs.dockerfile }} \
|
|
--opt filename=Dockerfile \
|
|
--output type=image,name=${{ inputs.tags }},push=true,registry.config=$DOCKER_CONFIG_DIR
|
|
|
|
|