mirror of
https://github.com/aevea/action-kaniko.git
synced 2025-01-30 22:09:37 +01:00
chore: Push on first build if skip_unchanged_digest isn't set
This commit is contained in:
parent
3b9302effb
commit
57d6d22cdf
1 changed files with 20 additions and 14 deletions
|
@ -45,7 +45,12 @@ export CACHE=$CACHE${INPUT_CACHE_REGISTRY:+" --cache-repo=$INPUT_CACHE_REGISTRY"
|
||||||
export CACHE=$CACHE${INPUT_CACHE_DIRECTORY:+" --cache-dir=$INPUT_CACHE_DIRECTORY"}
|
export CACHE=$CACHE${INPUT_CACHE_DIRECTORY:+" --cache-dir=$INPUT_CACHE_DIRECTORY"}
|
||||||
export CONTEXT="--context $GITHUB_WORKSPACE"
|
export CONTEXT="--context $GITHUB_WORKSPACE"
|
||||||
export DOCKERFILE="--dockerfile ${INPUT_BUILD_FILE:-Dockerfile}"
|
export DOCKERFILE="--dockerfile ${INPUT_BUILD_FILE:-Dockerfile}"
|
||||||
export DESTINATION="--no-push"
|
|
||||||
|
if [ ! -z $INPUT_SKIP_UNCHANGED_DIGEST ]; then
|
||||||
|
export DESTINATION="--no-push --digest-file digest"
|
||||||
|
else
|
||||||
|
export DESTINATION="--destination $IMAGE"
|
||||||
|
fi
|
||||||
|
|
||||||
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
||||||
|
|
||||||
|
@ -60,17 +65,17 @@ cat <<EOF >/kaniko/.docker/config.json
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
/kaniko/executor --digest-file digest --reproducible $ARGS
|
/kaniko/executor --reproducible $ARGS
|
||||||
|
|
||||||
|
if [ ! -z $INPUT_SKIP_UNCHANGED_DIGEST ]; then
|
||||||
export DIGEST=$(cat digest)
|
export DIGEST=$(cat digest)
|
||||||
export REMOTE=$(reg digest "$IMAGE" | tail -1)
|
export REMOTE=$(reg digest "$IMAGE" | tail -1)
|
||||||
|
|
||||||
if [ ! -z $INPUT_SKIP_UNCHANGED_DIGEST ]; then
|
|
||||||
if [ "$DIGEST" == "$REMOTE" ]; then
|
if [ "$DIGEST" == "$REMOTE" ]; then
|
||||||
echo "Digest hasn't changed, skipping, $DIGEST"
|
echo "Digest hasn't changed, skipping, $DIGEST"
|
||||||
|
echo "Done 🎉️"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
export DESTINATION="--destination $IMAGE"
|
export DESTINATION="--destination $IMAGE"
|
||||||
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $INPUT_EXTRA_ARGS"
|
||||||
|
@ -80,3 +85,4 @@ echo "Pushing image..."
|
||||||
/kaniko/executor --reproducible $ARGS >/dev/null 2>&1
|
/kaniko/executor --reproducible $ARGS >/dev/null 2>&1
|
||||||
|
|
||||||
echo "Done 🎉️"
|
echo "Done 🎉️"
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue