From dc53dd09d66a9a63261b6e83c108e46342a76861 Mon Sep 17 00:00:00 2001 From: Alex Viscreanu Date: Sat, 15 Feb 2020 18:55:26 +0100 Subject: [PATCH] Initial commit --- .dockerignore | 3 +++ .gitignore | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 5 ++++ action.yml | 27 +++++++++++++++++++ entrypoint.sh | 32 ++++++++++++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c9c8ccc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +* +!entrypoint.sh + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f81b0aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,75 @@ +#### joe made this: http://goel.io/joe + +#####=== macOS ===##### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +#####=== Windows ===##### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +#####=== Linux ===##### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +#####=== Custom ===##### +.direnv +.envrc +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..014baeb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM gcr.io/kaniko-project/executor:debug + +COPY entrypoint.sh / + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..14330ad --- /dev/null +++ b/action.yml @@ -0,0 +1,27 @@ +# kaniko.yml +name: "Kaniko builder" +description: "Build and push docker images using Kaniko" +inputs: + registry: + description: "Docker registry where the image will be pushed" + required: false + default: "docker.io" + username: + description: "Username used for authentication to the Docker registry" + required: false + default: "$GITHUB_ACTOR" + password: + description: "Password used for authentication to the Docker registry" + required: false + default: "$GITHUB_TOKEN" + image: + description: "Image name" + required: false + default: "$GITHUB_REPOSITORY" + tag: + description: "Image tag" + required: false + default: "$GITHUB_REF (master -> latest)" +runs: + using: "docker" + image: "Dockerfile" diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..b057804 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,32 @@ +#!/busybox/sh +set -e pipefail + +export REGISTRY=${INPUT_REGISTRY:-"docker.io"} +export IMAGE=${INPUT_IMAGE:-$GITHUB_REPOSITORY} +export TAG=${INPUT_TAG:-$([ "$GITHUB_REF" == "master" ] && echo latest || echo $GITHUB_REF)} +export TAG=${TAG:-"latest"} +export USERNAME=${INPUT_USERNAME:-$GITHUB_ACTOR} +export PASSWORD=${INPUT_PASSWORD:-$GITHUB_TOKEN} + +if[ "$INPUT_CACHE" == "true" ]; then + export CACHE="--cache=true --cache-ttl=${INPUT_CACHE_TTL:-168h}"; +fi + +export CONTEXT="--context $GITHUB_WORKSPACE" +export DOCKERFILE="--dockerfile ${INPUT_BUILD_FILE:-Dockerfile}" +export DESTINATION="--destination $REGISTRY/$IMAGE${IMAGE_NAMESPACE}:$TAG" + +export ARGS="$CACHE $CONTEXT $DOCKERFILE $DESTINATION $EXTRA" + +cat << EOF > /kaniko/.docker/config.json +{ + "auths": { + "${REGISTRY}": { + "username": "${USERNAME}", + "password": "${PASSWORD}" + } + } +} +EOF + +/kaniko/executor $ARGS