From 48c8a1793afca12a6e5145bd80e6ef89fc9a4d3d Mon Sep 17 00:00:00 2001 From: divolgin Date: Wed, 17 Jul 2024 11:47:13 -0700 Subject: [PATCH 1/3] no empty quotes for curl --- src/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index fda7037..07fbd63 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -40,7 +40,7 @@ function parse_inputs { enable_alpha_plugins="--enable_alpha_plugins" fi - with_token="" + with_token=() if [ "${INPUT_TOKEN}" != "" ]; then with_token=(-H "Authorization: token ${INPUT_TOKEN}") fi From 502e5d02175b0d28e261d98f89c8abebe38540bd Mon Sep 17 00:00:00 2001 From: Jonas Bergler Date: Sat, 17 May 2025 13:07:59 +1200 Subject: [PATCH 2/3] fix alpha plugin syntax on newer versions --- Dockerfile | 2 +- src/entrypoint.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d5c05dd..729107d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:3 -RUN apk add --update --no-cache bash ca-certificates curl git jq openssh +RUN apk add --update --no-cache bash ca-certificates curl git jq openssh lastversion RUN ["bin/sh", "-c", "mkdir -p /src"] COPY ["src", "/src/"] ENTRYPOINT ["/src/entrypoint.sh"] \ No newline at end of file diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 07fbd63..384210b 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -37,7 +37,11 @@ function parse_inputs { enable_alpha_plugins="" if [ "${INPUT_ENABLE_ALPHA_PLUGINS}" == "1" ] || [ "${INPUT_ENABLE_ALPHA_PLUGINS}" == "true" ]; then - enable_alpha_plugins="--enable_alpha_plugins" + if lastversion "${kustomize_version}" --newer-than "4.0.0"; then + enable_alpha_plugins="--enable-alpha-plugins" + else + enable_alpha_plugins="--enable_alpha_plugins" + fi fi with_token=() From 4b3f0883d155e3672b414ada46f3e514864da161 Mon Sep 17 00:00:00 2001 From: Jonas Bergler Date: Sat, 17 May 2025 13:08:13 +1200 Subject: [PATCH 3/3] add helm support --- Dockerfile | 2 +- README.md | 1 + action.yml | 4 ++++ src/entrypoint.sh | 34 ++++++++++++++++++++++++++++++---- src/kustomize_build.sh | 2 +- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 729107d..2b8ce61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:3 -RUN apk add --update --no-cache bash ca-certificates curl git jq openssh lastversion +RUN apk add --update --no-cache bash ca-certificates curl git jq openssh tar lastversion RUN ["bin/sh", "-c", "mkdir -p /src"] COPY ["src", "/src/"] ENTRYPOINT ["/src/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 64c2896..7ba3aaa 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Inputs configure Kustomize GitHub Actions to perform build action. * `kustomize_output_file` - (Optional) Path to to file to write the kustomize build output to. * `kustomize_build_options` - (Optional) Provide build options to kustomize build. * `enable_alpha_plugins` - (Optional) Enable Kustomize plugins. Defaults to `false`. +* `helm_version` - (Optional) The helm version to install and use for `kustomize build --enable-helm` ## Outputs diff --git a/action.yml b/action.yml index edb0839..00bb528 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,10 @@ inputs: description: 'Enable Kustomize plugins' required: false default: '0' + helm_version: + description: 'Specify the version of helm to use (also passes --enable-helm)' + required: false + default: '' token: description: 'GitHub Token for Authentication to Github API (mainly for limit avoidance)' required: false diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 384210b..0c105bc 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -44,6 +44,13 @@ function parse_inputs { fi fi + enable_helm="" + helm_version="" + if [ -n "${INPUT_HELM_VERSION}" ]; then + enable_helm="--enable-helm" + helm_version=${INPUT_HELM_VERSION} + fi + with_token=() if [ "${INPUT_TOKEN}" != "" ]; then with_token=(-H "Authorization: token ${INPUT_TOKEN}") @@ -90,18 +97,37 @@ function install_kustomize { } +function install_helm { + url="https://get.helm.sh/helm-v${helm_version}-linux-amd64.tar.gz" + + + echo "Downloading helm v${helm_version}" + curl --retry 30 --retry-max-time 120 -s -S -L ${url} | tar -xzv -C /usr/bin --strip-components=1 --wildcards 'linux-*/helm' + if [ "${?}" -ne 0 ]; then + echo "Failed to download helm v${helm_version}." + exit 1 + fi + echo "Successfully downloaded helm v${helm_version}." + + echo "Allowing execute privilege to helm." + chmod +x /usr/bin/helm + if [ "${?}" -ne 0 ]; then + echo "Failed to update helm privilege." + exit 1 + fi + echo "Successfully added execute privilege to helm." +} + function main { scriptDir=$(dirname ${0}) source ${scriptDir}/kustomize_build.sh parse_inputs - if [ "${kustomize_install}" == "1" ]; then - install_kustomize - fi + [ "${kustomize_install}" == "1" ] && install_kustomize + [ -n "${helm_version}" ] && install_helm kustomize_build - } main "${*}" diff --git a/src/kustomize_build.sh b/src/kustomize_build.sh index e3cebe2..b8b86a1 100755 --- a/src/kustomize_build.sh +++ b/src/kustomize_build.sh @@ -4,7 +4,7 @@ function kustomize_build { # gather output echo "build: info: kustomize build in directory ${kustomize_build_dir}." - build_output=$(kustomize build ${enable_alpha_plugins} ${kustomize_build_options} ${kustomize_build_dir} 2>&1) + build_output=$(kustomize build ${enable_alpha_plugins} ${enable_helm} ${kustomize_build_options} ${kustomize_build_dir} 2>&1) build_exit_code=${?}