diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 736d40d..0000000 --- a/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM gcr.io/kaniko-project/executor:debug -COPY build.sh /usr/local/bin/ -ENTRYPOINT ["build.sh"] diff --git a/action.yaml b/action.yaml index 99067e8..64d2fbf 100644 --- a/action.yaml +++ b/action.yaml @@ -16,12 +16,14 @@ inputs: required: true runs: - using: docker - image: Dockerfile - args: - - ACTION_DOCKERFILE=${{ inputs.dockerfile }} - - ACTION_TAG=${{ inputs.tag }} - - ACTION_REGISTRY=${{ gitea.server_url }} - - ACTION_IMAGE=${{ gitea.repository }} - - ACTION_USERNAME=${{ inputs.username }} - - ACTION_PASSWORD=${{ inputs.password }} + using: composite + steps: + - name: Build + run: ${{ gitea.action_path }}/build.sh + env: + - ACTION_DOCKERFILE=${{ inputs.dockerfile }} + - ACTION_TAG=${{ inputs.tag }} + - ACTION_REGISTRY=${{ gitea.server_url }} + - ACTION_IMAGE=${{ gitea.repository }} + - ACTION_USERNAME=${{ inputs.username }} + - ACTION_PASSWORD=${{ inputs.password }} diff --git a/build.sh b/build.sh old mode 100755 new mode 100644 index e656c31..5c4bf17 --- a/build.sh +++ b/build.sh @@ -1,9 +1,8 @@ -#!/bin/sh -ex +#!/bin/bash -e -# source environment from args -eval "$*" +exec 3<> /dev/tty -cat < /kaniko/.docker/config.json +cat <&3 { "auths": { "$ACTION_REGISTRY": { @@ -14,8 +13,13 @@ cat < /kaniko/.docker/config.json } EOF -REGISTRY="$(echo "$ACTION_REGISTRY" | sed 's .*:// ')" -/kaniko/executor \ - --context "${ACTION_DOCKERFILE%/*}" \ - --dockerfile "$ACTION_DOCKERFILE" \ - --destination "$REGISTRY/$ACTION_IMAGE:$ACTION_TAG" +REGISTRY="${ACTION_REGISTRY/https:\/\/}" +docker run --rm \ + -v "$PWD:$PWD:ro" \ + -v "$HOME/.cache/kaniko:/cache" \ + -v "/proc/$$/fd/3:/kaniko/.docker/config.json:ro" \ + gcr.io/kaniko-project/executor:latest \ + --cache true \ + --context "${ACTION_DOCKERFILE%/*}" \ + --dockerfile "$ACTION_DOCKERFILE" \ + --destination "$REGISTRY/$ACTION_IMAGE:$ACTION_TAG"