diff --git a/index.js b/index.js index c8b479e..6e9b6bc 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,21 @@ import core from "@actions/core"; import exec from "@actions/exec"; +import { parseCSV } from "@google-github-actions/actions-utils"; import { promises as fsp } from "fs"; -const getValues = (values) => { - if (!values) { - return JSON.stringify({}); - } - if (typeof values === "object") { - return JSON.stringify(values); +const getValues = (input) => { + const values = []; + + for (const line of input.split(/\r|\n/)) { + const pieces = parseCSV(line); + + for (const piece of pieces) { + const [key, value] = piece.trim().split('=', 2); + + values.push([key, value]); + } } + return values; }; @@ -87,6 +94,12 @@ const run = async () => { // Set default tag field to "image.tag" if (tagFields.length === 0) tagFields = ["image.tag"] + if (values) { + for (const [key, value] of values) { + args.push(`--set=${key}=${value}`); + } + } + if (image) { for (const imageField of imageFields) { args.push(`--set=${imageField}=${image}`); @@ -111,10 +124,6 @@ const run = async () => { // Add all the Helm Secrets files secretsFiles.forEach((f) => args.push(`--values=secrets://${f}`)); - // Add the individually added values - await fsp.writeFile("/values.yml", values); - args.push("--values=/values.yml"); - // Setup the Kubeconfig file if (process.env.KUBECONFIG_FILE) { process.env.KUBECONFIG = "/kubeconfig.yml"; diff --git a/package.json b/package.json index 40648ff..0409344 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "license": "MIT", "dependencies": { "@actions/core": "^1.9.1", - "@actions/exec": "^1.0.4" + "@actions/exec": "^1.0.4", + "@google-github-actions/actions-utils": "^0.8.2" } } diff --git a/yarn.lock b/yarn.lock index 7b6eec2..ce786b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -35,6 +35,13 @@ resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d" integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA== +"@google-github-actions/actions-utils@^0.8.2": + version "0.8.2" + resolved "https://registry.yarnpkg.com/@google-github-actions/actions-utils/-/actions-utils-0.8.2.tgz#c92f233135b517250b011c2fe5d0aeedb27b0c2d" + integrity sha512-kIa7kbCKQTSw6xj+e3Gi1yDWnbxOSVssSYdOvuE0VyDZCRHuEgIbjyq+a1tc+hGf3mGg/x5aZaD3IkNaPZ6kuA== + dependencies: + yaml "^2.4.2" + tunnel@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" @@ -51,3 +58,8 @@ uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + +yaml@^2.4.2: + version "2.4.5" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.4.5.tgz#60630b206dd6d84df97003d33fc1ddf6296cca5e" + integrity sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==