diff --git a/Dockerfile b/Dockerfile index 841c238..6f58631 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,5 @@ -FROM stefanprodan/alpine-base:latest - -RUN apk --no-cache add git +FROM devthefuture/init-container-toolbox:latest COPY src/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 3f49b4b..0bff3f4 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ Inputs: * `index_dir` The location of `index.yaml` file in the repo, defaults to the same value as `target_dir` * `enterprise_url` The URL of enterprise github server in the format `/` * `dependencies` A list of helm repositories required to verify dependencies in the format `,;,` or if using private repositories `,,,;,,,`. Combinations are allowed. +* `repo_url` The URL of the git repository +* `ssh_private_key` SSH private key for ssh connection to the target repository ## Examples diff --git a/action.yml b/action.yml index 946063d..31fe350 100644 --- a/action.yml +++ b/action.yml @@ -55,6 +55,12 @@ inputs: dependencies: description: "A list of helm repositories required to verify dependencies in the format ',;,'" required: false + repo_url: + description: "The URL of the git repository" + required: false + ssh_private_key: + description: "SSH private key for ssh connection to the target repository" + required: false runs: using: 'docker' image: 'Dockerfile' @@ -75,3 +81,5 @@ runs: - ${{ inputs.index_dir }} - ${{ inputs.enterprise_url }} - ${{ inputs.dependencies }} + - ${{ inputs.repo_url }} + - ${{ inputs.ssh_private_key }} diff --git a/src/entrypoint.sh b/src/entrypoint.sh old mode 100644 new mode 100755 index 3f189d3..c9eb5df --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -1,19 +1,5 @@ #!/usr/bin/env bash -# Copyright 2020 Stefan Prodan. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - set -o errexit set -o pipefail @@ -33,11 +19,11 @@ CHART_VERSION=${13} INDEX_DIR=${14} ENTERPRISE_URL=${15} DEPENDENCIES=${16} +REPO_URL=${17} +SSH_PRIVATE_KEY=${18} CHARTS=() CHARTS_TMP_DIR=$(mktemp -d) -REPO_ROOT=$(git rev-parse --show-toplevel) -REPO_URL="" main() { if [[ -z "$HELM_VERSION" ]]; then @@ -170,6 +156,13 @@ upload() { tmpDir=$(mktemp -d) pushd $tmpDir >& /dev/null + if [ -n "$SSH_PRIVATE_KEY" ]; then + mkdir -p ~/.ssh + echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + export GIT_SSH_COMMAND="ssh -v -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no" + fi + git clone ${REPO_URL} cd ${REPOSITORY} git config user.name "${COMMIT_USERNAME}"