-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM alpine/helm:2.14.0 | ||
RUN apk add --no-cache jq curl bash nodejs && helm init --client-only | ||
COPY . /usr/src/ | ||
ENTRYPOINT ["node", "/usr/src/index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: 'Deliverybot Helm Action' | ||
description: 'Deploys a helm chart' | ||
author: 'deliverybot' | ||
inputs: | ||
release: | ||
description: 'Helm release name' | ||
namespace: | ||
description: 'Kubernetes namespace name' | ||
chart: | ||
description: 'Helm chart name' | ||
values: | ||
description: 'Helm chart values, expected to be a YAML or JSON string' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const core = require("@actions/core"); | ||
const github = require("@actions/github"); | ||
const exec = require("@actions/exec"); | ||
const fs = require("fs"); | ||
const util = require("util"); | ||
|
||
const writeFile = util.promisify(fs.writeFile); | ||
|
||
const required = { required: true }; | ||
|
||
async function run() { | ||
try { | ||
const release = core.getInput("release", required); | ||
const namespace = core.getInput("namespace", required); | ||
const chart = core.getInput("chart", required); | ||
const values = core.getInput("values"); | ||
const context = github.context; | ||
const deployment = context.payload.deployment; | ||
const opts = { | ||
env: { | ||
KUBECONFIG: "./kubeconfig.yml", | ||
} | ||
} | ||
|
||
await writeFile("./kubeconfig.yml", process.env.KUBECONFIG); | ||
await writeFile("./values.yml", values); | ||
|
||
if (deployment.task === "remove") { | ||
exec.exec("helm", ["delete", release, "--purge"], opts); | ||
} else { | ||
exec.exec("helm", [ | ||
"upgrade", release, chart, "--install", "--wait", "--atomic", | ||
"--namespace", namespace, "--values" | ||
], opts); | ||
} | ||
} catch (error) { | ||
core.error(error); | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run(); |