feat: read Dockerfile from local file system

This commit is contained in:
Leandro Costa 2025-06-17 12:20:18 -03:00
parent 43c892c45f
commit 0b74179a32

View file

@ -2,9 +2,9 @@
name: Kaniko
description: Build a container image using Kaniko
inputs:
Dockerfile:
dockerfile:
description: The Dockerfile to pass to Kaniko
required: true
required: false
image:
description: Name and tag under which to upload the image
required: true
@ -27,7 +27,18 @@ runs:
- |
mkdir -p /kaniko/.docker
echo '{"auths":{"${{ inputs.registry }}":{"auth":"'$(printf "%s:%s" "${{ inputs.username }}" "${{ inputs.password }}" | base64 | tr -d '\n')'"}}}' > /kaniko/.docker/config.json
cat > Dockerfile <<EOF
${{ inputs.Dockerfile }}
EOF
/kaniko/executor --dockerfile Dockerfile --destination ${{ inputs.image }}
if [ -n "${{ inputs.dockerfile }}" ]; then
echo "Using Dockerfile from input"
echo "${{ inputs.dockerfile }}" > Dockerfile
elif [ -f "./Dockerfile" ]; then
echo "Using existing ./Dockerfile from workspace"
else
echo "ERROR: No Dockerfile provided and no ./Dockerfile found in workspace"
exit 1
fi
echo "Files on current directory"
ls -lha
/kaniko/executor --dockerfile Dockerfile --destination "${{ inputs.image }}"