diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6efd6d24..0666f55c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: uses: 'actions/checkout@v1' - name: 'Deploy Canary' - uses: 'deliverybot/helm@ci-v2' + uses: 'deliverybot/helm@master' with: helm: helm3 token: '${{ github.token }}' @@ -39,7 +39,7 @@ jobs: KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' - name: 'Deploy Production' - uses: 'deliverybot/helm@ci-v2' + uses: 'deliverybot/helm@master' with: helm: helm3 token: '${{ github.token }}' diff --git a/index.js b/index.js index 3fdd8939..308eae79 100644 --- a/index.js +++ b/index.js @@ -128,6 +128,20 @@ function renderFiles(files, data) { return Promise.all(promises); } +/** + * Makes a delete command for compatibility between helm 2 and 3. + * + * @param {string} helm + * @param {string} namespace + * @param {string} release + */ +function deleteCmd(helm, namespace, release) { + if (helm === "helm3") { + return ["delete", "-n", namespace, release]; + } + return ["delete", release]; +} + /** * Run executes the helm deployment. */ @@ -206,7 +220,7 @@ async function run() { // Remove the canary deployment before continuing. if (removeCanary) { core.debug(`removing canary ${appName}-canary`); - await exec.exec(helm, ["delete", `${appName}-canary`], { + await exec.exec(helm, deleteCmd(helm, namespace, `${appName}-canary`), { ...opts, ignoreReturnCode: true }); @@ -214,7 +228,7 @@ async function run() { // Actually execute the deployment here. if (task === "remove") { - await exec.exec(helm, ["delete", release], { + await exec.exec(helm, deleteCmd(helm, namespace, release), { ...opts, ignoreReturnCode: true });