Skip to content

Commit

Permalink
feat: Add flag for atomic variable (#45)
Browse files Browse the repository at this point in the history
Not every deployment should be rolled back when the deployment fails. Add a
flag to enable the atomic parameter.
  • Loading branch information
Jelle van Oosterbosch authored Jan 9, 2021
1 parent 0ce1ab7 commit c5da4d5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`);
Expand All @@ -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.
Expand All @@ -194,7 +196,6 @@ async function run() {
chart,
"--install",
"--wait",
"--atomic",
`--namespace=${namespace}`,
];

Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit c5da4d5

Please sign in to comment.