BuildKit-build and push action - fix authentication on push
This commit is contained in:
@@ -28,30 +28,38 @@ inputs:
|
|||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Authenticate to Gitea registry
|
- name: run buildctl built and push
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# Create a temporary file inside GITHUB_TEMP
|
|
||||||
DOCKER_CONFIG_FILE="${GITHUB_TEMP}/docker_config.json"
|
|
||||||
|
|
||||||
# Ensure cleanup ALWAYS happens
|
# create docker config temp folder
|
||||||
trap 'rm -f "$DOCKER_CONFIG_FILE"' EXIT
|
DOCKER_CONFIG_DIR="${RUNNER_TEMP}/.buildctl_docker"
|
||||||
|
mkdir -p "$DOCKER_CONFIG_DIR"
|
||||||
|
|
||||||
# Generate auth entry
|
# clean up
|
||||||
|
trap 'rm -rf "$DOCKER_CONFIG_DIR"' EXIT
|
||||||
|
|
||||||
|
|
||||||
|
# setup file docker config (auth) temp file
|
||||||
AUTH=$(printf "%s" "${{ inputs.registry_username }}:${{ inputs.registry_password }}" | base64 -w 0)
|
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
|
||||||
|
|
||||||
printf '{"auths":{"%s":{"auth":"%s"}}}' \
|
# Run BuildKit build, set DOCKER_CONFIG to DOCKER_CONFIG_DIR so auth works on push
|
||||||
"${{ inputs.registry_addr }}" \
|
DOCKER_CONFIG=$DOCKER_CONFIG_DIR buildctl \
|
||||||
"$AUTH" \
|
|
||||||
> "$DOCKER_CONFIG_FILE"
|
|
||||||
|
|
||||||
# Run BuildKit build
|
|
||||||
buildctl \
|
|
||||||
--addr ${{ inputs.buildkit_addr }} \
|
--addr ${{ inputs.buildkit_addr }} \
|
||||||
build \
|
build \
|
||||||
--frontend=dockerfile.v0 \
|
--frontend=dockerfile.v0 \
|
||||||
--local context=${{ inputs.context }} \
|
--local context=${{ inputs.context }} \
|
||||||
--local dockerfile=${{ inputs.dockerfile }} \
|
--local dockerfile=${{ inputs.dockerfile }} \
|
||||||
--opt filename=Dockerfile \
|
--opt filename=Dockerfile \
|
||||||
--output type=image,name=${{ inputs.tags }},push=true,registry.config=$DOCKER_CONFIG_FILE
|
--output type=image,name=${{ inputs.tags }},push=true
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user