From a8457b86ccc68a7d3eb24d494a2a0cb55e43a5b0 Mon Sep 17 00:00:00 2001 From: Jelle van Oosterbosch Date: Mon, 9 Nov 2020 09:21:16 +0100 Subject: [PATCH] Made the atomic option configurable --- README.md | 1 + action.yml | 8 +++++++- index.js | 8 +++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 854f1015..4b4af856 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ payload if the action was triggered by a deployment. - `version`: Version of the app, usually commit sha works here. - `timeout`: specify a timeout for helm deployment - `repository`: specify the URL for a helm repo to come from +- `atomic`: If true, upgrade process rolls back changes made in case of failed upgrade. Defaults to true. Additional parameters: If the action is being triggered by a deployment event and the `task` parameter in the deployment event is set to `"remove"` then this diff --git a/action.yml b/action.yml index 08f6242a..8679e0ea 100644 --- a/action.yml +++ b/action.yml @@ -17,10 +17,16 @@ inputs: values: description: Helm chart values, expected to be a YAML or JSON string. required: false - dry-run: + task: description: Task name. If the task is "remove" it will remove the configured helm release. required: false + dry-run: + description: Simulate an upgrade. + required: false + atomic: + description: If true, upgrade process rolls back changes made in case of failed upgrade. Defaults to true. + required: false helm: description: Helm binary to execute, one of [helm, helm3]. required: false diff --git a/index.js b/index.js index 498334b3..e49304e6 100644 --- a/index.js +++ b/index.js @@ -169,6 +169,7 @@ async function run() { const repository = getInput("repository"); const dryRun = core.getInput("dry-run"); const secrets = getSecrets(core.getInput("secrets")); + const atomic = getInput("atomic") || true; core.debug(`param: track = "${track}"`); core.debug(`param: release = "${release}"`); @@ -185,6 +186,7 @@ async function run() { core.debug(`param: removeCanary = ${removeCanary}`); core.debug(`param: timeout = "${timeout}"`); core.debug(`param: repository = "${repository}"`); + core.debug(`param: atomic = "${atomic}"`); // Setup command options and arguments. @@ -194,7 +196,6 @@ async function run() { chart, "--install", "--wait", - "--atomic", `--namespace=${namespace}`, ]; @@ -223,6 +224,11 @@ async function run() { args.push("--set=service.enabled=false", "--set=ingress.enabled=false"); } + // If true upgrade process rolls back changes made in case of failed upgrade. + if (atomic === true) { + args.push("--atomic"); + } + // Setup necessary files. if (process.env.KUBECONFIG_FILE) { process.env.KUBECONFIG = "./kubeconfig.yml";