Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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 tar lastversion
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tar - because the busybox tar doesn't support wildcard
lastversion - because it provides an easy way to do semver comparisons (for the alpha plugins syntax)

RUN ["bin/sh", "-c", "mkdir -p /src"]
COPY ["src", "/src/"]
ENTRYPOINT ["/src/entrypoint.sh"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 36 additions & 6 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,21 @@ 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

enable_helm=""
helm_version=""
if [ -n "${INPUT_HELM_VERSION}" ]; then
enable_helm="--enable-helm"
helm_version=${INPUT_HELM_VERSION}
fi

with_token=""
with_token=()
if [ "${INPUT_TOKEN}" != "" ]; then
with_token=(-H "Authorization: token ${INPUT_TOKEN}")
fi
Expand Down Expand Up @@ -86,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 "${*}"
2 changes: 1 addition & 1 deletion src/kustomize_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=${?}

Expand Down