From 26a8746cddcc464e7123a83f36ce92145563559e Mon Sep 17 00:00:00 2001 From: koslib Date: Sun, 2 Jan 2022 21:26:11 +0200 Subject: [PATCH 1/3] Added support for optional helm plugins --- action.yml | 3 +++ entrypoint.sh | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e092207..601d788 100644 --- a/action.yml +++ b/action.yml @@ -7,6 +7,9 @@ inputs: command: description: "Your command (kubectl or helm)" required: true + plugins: + description: "Comma-separated URLs for the Helm Plugins you need installed" + required: false outputs: result: description: "Output returned by your Helm or kubectl command" diff --git a/entrypoint.sh b/entrypoint.sh index 4073373..c3007c3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,8 +5,16 @@ set -e echo ${KUBE_CONFIG_DATA} | base64 -d > kubeconfig export KUBECONFIG="${PWD}/kubeconfig" +plugins=$(echo $INPUT_PLUGINS | tr ",") + +for plugin in $plugins +do + echo "installing helm plugin: [$plugin]" + helm plugin install $plugin +done + echo "running entrypoint command(s)" -response=$(sh -c " $*") +response=$(sh -c " $INPUT_COMMAND") echo "::set-output name=response::$response" From 0b26aee480b80ad6c1999b56ea6e1546a22ea64d Mon Sep 17 00:00:00 2001 From: koslib Date: Sun, 2 Jan 2022 21:39:43 +0200 Subject: [PATCH 2/3] Install helm plugins only if variable is not empty --- entrypoint.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index c3007c3..b03edcc 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,13 +5,16 @@ set -e echo ${KUBE_CONFIG_DATA} | base64 -d > kubeconfig export KUBECONFIG="${PWD}/kubeconfig" -plugins=$(echo $INPUT_PLUGINS | tr ",") +if [-z $INPUT_PLUGINS] +then + plugins=$(echo $INPUT_PLUGINS | tr ",") -for plugin in $plugins -do - echo "installing helm plugin: [$plugin]" - helm plugin install $plugin -done + for plugin in $plugins + do + echo "installing helm plugin: [$plugin]" + helm plugin install $plugin + done +fi echo "running entrypoint command(s)" From 25e7264acb9701cd9a9bb4c57a7aa963194520a6 Mon Sep 17 00:00:00 2001 From: koslib Date: Sun, 2 Jan 2022 21:46:32 +0200 Subject: [PATCH 3/3] Updated readme to reflect helm plugin changes --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index a641837..10e1d3c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,20 @@ This action was inspired by [kubernetes-action](https://github.com/Jberlinsky/ku This Github Action was created with EKS in mind, therefore the following example refers to it. +## Input variables + +1. `plugins`: you can specify a list of Helm plugins you'd like to install and use later on in your command. eg. helm-secrets or helm-diff. This action does not support only a specific list of Helm plugins, rather any Helm plugin as long as you supply its URL. You can use the following [example](#example) as a reference. +2. `command`: your kubectl/helm command. This supports multiline as per the Github Actions workflow syntax. + +example for multiline: +```yaml +... +with: + command: | + helm upgrade --install my-release chart/repo + kubectl get pods +``` + ## Example ```yaml @@ -38,6 +52,7 @@ jobs: env: KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} with: + plugins: "https://github.com/jkroepke/helm-secrets" # optional command: helm upgrade --install --wait -f ```