Skip to content

Commit

Permalink
Merge pull request #2 from vimeda/merge-upstream-master
Browse files Browse the repository at this point in the history
Merge upstream master
  • Loading branch information
mpraski authored Jan 25, 2021
2 parents ea3f24e + c7179e4 commit 6924066
Show file tree
Hide file tree
Showing 33 changed files with 932 additions and 521 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.7.0](https://github.com/deliverybot/helm/compare/v1.6.1...v1.7.0) (2021-01-09)


### Features

* Add flag for atomic variable ([#45](https://github.com/deliverybot/helm/issues/45)) ([c5da4d5](https://github.com/deliverybot/helm/commit/c5da4d5cd0cba39b959459af1da0b5e3ed9b887f))
* Add required parameter to all action inputs ([#33](https://github.com/deliverybot/helm/issues/33)) ([7035d19](https://github.com/deliverybot/helm/commit/7035d19603bf6ead15e61b8feba0f0feec9d9861))
* Upgrade helm ([#50](https://github.com/deliverybot/helm/issues/50)) ([0ce1ab7](https://github.com/deliverybot/helm/commit/0ce1ab79060b30006b1800919d61332ed279d75f))

### [1.6.1](https://github.com/deliverybot/helm/compare/v1.6.0...v1.6.1) (2020-06-06)


### Bug Fixes

* Remove colon in action.yml ([1f0d808](https://github.com/deliverybot/helm/commit/1f0d808b77f835b1547c80cdd5080a217465cefe))

## [1.6.0](https://github.com/deliverybot/helm/compare/v1.5.0...v1.6.0) (2020-06-06)


### Features

* Add additional parameters to download a chart by url ([#23](https://github.com/deliverybot/helm/issues/23)) ([547935f](https://github.com/deliverybot/helm/commit/547935f280af50b2cb7f7fcfd08c29f367433395))
* Add missing `helm` input parameter to action.yml ([#29](https://github.com/deliverybot/helm/issues/29)) ([8612a75](https://github.com/deliverybot/helm/commit/8612a75699d4ca8ea60072bb3350f4d26095ad27))
* Add support for EKS clusters and fix helm v3 home issue ([#27](https://github.com/deliverybot/helm/issues/27)) ([70b15cc](https://github.com/deliverybot/helm/commit/70b15cc0dc343686882dfb9185ff67cef9d47723)), closes [#22](https://github.com/deliverybot/helm/issues/22)

## [1.5.0](https://github.com/deliverybot/helm/compare/v1.4.0...v1.5.0) (2019-12-24)


Expand Down
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ FROM alpine:3.10.2

ENV BASE_URL="https://get.helm.sh"

ENV HELM_2_FILE="helm-v2.16.1-linux-amd64.tar.gz"
ENV HELM_3_FILE="helm-v3.0.2-linux-amd64.tar.gz"
ENV HELM_2_FILE="helm-v2.17.0-linux-amd64.tar.gz"
ENV HELM_3_FILE="helm-v3.4.2-linux-amd64.tar.gz"

RUN apk add --no-cache ca-certificates jq curl bash nodejs && \
RUN apk add --no-cache ca-certificates \
--repository http://dl-3.alpinelinux.org/alpine/edge/community/ \
jq curl bash nodejs aws-cli && \
# Install helm version 2:
curl -L ${BASE_URL}/${HELM_2_FILE} |tar xvz && \
mv linux-amd64/helm /usr/bin/helm && \
Expand All @@ -19,5 +21,7 @@ RUN apk add --no-cache ca-certificates jq curl bash nodejs && \
# Init version 2 helm:
helm init --client-only

ENV PYTHONPATH "/usr/lib/python3.8/site-packages/"

COPY . /usr/src/
ENTRYPOINT ["node", "/usr/src/index.js"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ payload if the action was triggered by a deployment.
- `namespace`: Kubernetes namespace name. (required)
- `chart`: Helm chart path. If set to "app" this will use the built in helm
chart found in this repository. (required)
- `chart_version`: The version of the helm chart you want to deploy (distinct from app version)
- `values`: Helm chart values, expected to be a YAML or JSON string.
- `track`: Track for the deployment. If the track is not "stable" it activates
the canary workflow described below.
Expand All @@ -37,6 +38,7 @@ payload if the action was triggered by a deployment.
- `repo-alias`: Helm repository alias that will be used.
- `repo-username`: Helm repository username if authentication is needed.
- `repo-password`: Helm repository password if authentication is needed.
- `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 Expand Up @@ -81,6 +83,11 @@ jobs:
token: '${{ github.token }}'
values: |
name: foobar
value-files: >-
[
"values.yaml",
"values.production.yaml"
]
env:
KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}'
```
Expand Down
29 changes: 13 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,31 @@ branding:
color: gray-dark
inputs:
release:
description: Helm release name. Will be combined with track if set.
description: Helm release name. Will be combined with track if set. (required)
required: true
namespace:
description: Kubernetes namespace name.
description: Kubernetes namespace name. (required)
required: true
chart:
description: Helm chart path. If set to "app" this will use the built in helm
chart found in this repository.
chart found in this repository. (required)
required: true
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
token:
description: Github repository token. If included and the event is a deployment
the deployment_status event will be fired.
Expand All @@ -37,18 +46,6 @@ inputs:
version:
description: Version of the app, usually commit sha works here.
required: false
repo:
description: Helm chart repository to be added.
required: false
repo-alias:
description: Helm repository alias that will be used.
required: false
repo-username:
description: Helm repository username if authentication is needed.
required: false
repo-password:
description: Helm repository password if authentication is needed.
required: false
runs:
using: docker
image: Dockerfile
35 changes: 24 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ async function run() {
const release = releaseName(appName, track);
const namespace = getInput("namespace", required);
const chart = chartName(getInput("chart", required));
const chartVersion = getInput("chart_version");
const values = getValues(getInput("values"));
const task = getInput("task");
const version = getInput("version");
Expand All @@ -169,15 +170,16 @@ async function run() {
const repoAlias = getInput("repo-alias");
const repoUsername = getInput("repo-username");
const repoPassword = getInput("repo-password");

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}"`);
core.debug(`param: appName = "${appName}"`);
core.debug(`param: namespace = "${namespace}"`);
core.debug(`param: chart = "${chart}"`);
core.debug(`param: chart_version = "${chartVersion}"`);
core.debug(`param: values = "${values}"`);
core.debug(`param: dryRun = "${dryRun}"`);
core.debug(`param: task = "${task}"`);
Expand All @@ -186,27 +188,35 @@ async function run() {
core.debug(`param: valueFiles = "${JSON.stringify(valueFiles)}"`);
core.debug(`param: removeCanary = ${removeCanary}`);
core.debug(`param: timeout = "${timeout}"`);
core.debug(`param: atomic = "${atomic}"`);
core.debug(`param: repo = "${repo}"`);
core.debug(`param: repoAlias = "${repoAlias}"`);
core.debug(`param: repoUsername = "${repoUsername}"`);
core.debug(`param: repoPassword = "${repoPassword}"`);

// Setup command options and arguments.
const opts = { env: {
KUBECONFIG: process.env.KUBECONFIG,
}};
let args = [
"upgrade",
release,
chart,
"--install",
"--wait",
"--atomic",
`--namespace=${namespace}`,
];

// Per https://helm.sh/docs/faq/#xdg-base-directory-support
if (helm === "helm3") {
process.env.XDG_DATA_HOME = "/root/.helm/"
process.env.XDG_CACHE_HOME = "/root/.helm/"
process.env.XDG_CONFIG_HOME = "/root/.helm/"
} else {
process.env.HELM_HOME = "/root/.helm/"
}

if (dryRun) args.push("--dry-run");
if (appName) args.push(`--set=app.name=${appName}`);
if (version) args.push(`--set=app.version=${version}`);
if (chartVersion) args.push(`--version=${chartVersion}`);
if (timeout) args.push(`--timeout=${timeout}`);
valueFiles.forEach(f => args.push(`--values=${f}`));
args.push("--values=./values.yml");
Expand All @@ -218,14 +228,19 @@ 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) {
opts.env.KUBECONFIG = "./kubeconfig.yml";
await writeFile(opts.env.KUBECONFIG, process.env.KUBECONFIG_FILE);
process.env.KUBECONFIG = "./kubeconfig.yml";
await writeFile(process.env.KUBECONFIG, process.env.KUBECONFIG_FILE);
}
await writeFile("./values.yml", values);

core.debug(`env: KUBECONFIG="${opts.env.KUBECONFIG}"`);
core.debug(`env: KUBECONFIG="${process.env.KUBECONFIG}"`);

// Render value files using github variables.
await renderFiles(valueFiles.concat(["./values.yml"]), {
Expand All @@ -237,7 +252,6 @@ async function run() {
if (removeCanary) {
core.debug(`removing canary ${appName}-canary`);
await exec.exec(helm, deleteCmd(helm, namespace, `${appName}-canary`), {
...opts,
ignoreReturnCode: true
});
}
Expand Down Expand Up @@ -268,11 +282,10 @@ async function run() {
// Actually execute the deployment here.
if (task === "remove") {
await exec.exec(helm, deleteCmd(helm, namespace, release), {
...opts,
ignoreReturnCode: true
});
} else {
await exec.exec(helm, args, opts);
await exec.exec(helm, args);
}

await status(task === "remove" ? "inactive" : "success");
Expand Down
14 changes: 8 additions & 6 deletions node_modules/@actions/core/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6924066

Please sign in to comment.