From 620558a3ad4f12c8955717cff95accd671245ef4 Mon Sep 17 00:00:00 2001 From: Ben Connito Date: Sun, 1 Oct 2023 11:18:31 -0400 Subject: [PATCH] add artifacts-type-override to action.yml to specify the artifact type override --- action.yml | 3 +++ code-build.js | 15 +++++++++++++-- dist/index.js | 15 +++++++++++++-- test/code-build-test.js | 5 +---- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 054be7b..bb8f11a 100644 --- a/action.yml +++ b/action.yml @@ -40,6 +40,9 @@ inputs: disable-github-env-vars: description: 'Set to `true` if you want do disable github environment variables in codebuild' required: false + artifacts-type-override: + description: 'The type of build output artifact' + required: false outputs: aws-build-id: description: 'The AWS CodeBuild Build ID for this build.' diff --git a/code-build.js b/code-build.js index 41baa0f..2be65ce 100644 --- a/code-build.js +++ b/code-build.js @@ -222,6 +222,9 @@ function githubInputs() { const disableGithubEnvVars = core.getInput("disable-github-env-vars", { required: false }) === "true"; + const artifactsTypeOverride = + core.getInput("artifacts-type-override", { required: false }) || undefined; + return { projectName, owner, @@ -238,6 +241,7 @@ function githubInputs() { disableSourceOverride, hideCloudWatchLogs, disableGithubEnvVars, + artifactsTypeOverride, }; } @@ -255,6 +259,7 @@ function inputs2Parameters(inputs) { envPassthrough = [], disableSourceOverride, disableGithubEnvVars, + artifactsTypeOverride, } = inputs; const sourceOverride = !disableSourceOverride @@ -265,7 +270,13 @@ function inputs2Parameters(inputs) { } : {}; - const artifactsOverride = { type: "NO_ARTIFACTS" }; + const artifactsOverride = artifactsTypeOverride + ? { + artifactsOverride: { + type: artifactsTypeOverride, + }, + } + : {}; const environmentVariablesOverride = Object.entries(process.env) .filter( @@ -281,7 +292,7 @@ function inputs2Parameters(inputs) { projectName, ...sourceOverride, buildspecOverride, - artifactsOverride, + ...artifactsOverride, computeTypeOverride, environmentTypeOverride, imageOverride, diff --git a/dist/index.js b/dist/index.js index cf33952..23564d4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -228,6 +228,9 @@ function githubInputs() { const disableGithubEnvVars = core.getInput("disable-github-env-vars", { required: false }) === "true"; + const artifactsTypeOverride = + core.getInput("artifacts-type-override", { required: false }) || undefined; + return { projectName, owner, @@ -244,6 +247,7 @@ function githubInputs() { disableSourceOverride, hideCloudWatchLogs, disableGithubEnvVars, + artifactsTypeOverride, }; } @@ -261,6 +265,7 @@ function inputs2Parameters(inputs) { envPassthrough = [], disableSourceOverride, disableGithubEnvVars, + artifactsTypeOverride, } = inputs; const sourceOverride = !disableSourceOverride @@ -271,7 +276,13 @@ function inputs2Parameters(inputs) { } : {}; - const artifactsOverride = { type: "NO_ARTIFACTS" }; + const artifactsOverride = artifactsTypeOverride + ? { + artifactsOverride: { + type: artifactsTypeOverride, + }, + } + : {}; const environmentVariablesOverride = Object.entries(process.env) .filter( @@ -287,7 +298,7 @@ function inputs2Parameters(inputs) { projectName, ...sourceOverride, buildspecOverride, - artifactsOverride, + ...artifactsOverride, computeTypeOverride, environmentTypeOverride, imageOverride, diff --git a/test/code-build-test.js b/test/code-build-test.js index a2c7b92..1dbb12b 100644 --- a/test/code-build-test.js +++ b/test/code-build-test.js @@ -244,10 +244,6 @@ describe("inputs2Parameters", () => { expect(test) .to.haveOwnProperty("sourceLocationOverride") .and.to.equal(`https://github.com/owner/repo.git`); - expect(test) - .to.haveOwnProperty("artifactsOverride") - .that.has.property("type") - .that.equals("NO_ARTIFACTS"); expect(test) .to.haveOwnProperty("buildspecOverride") .and.to.equal(undefined); @@ -300,6 +296,7 @@ describe("inputs2Parameters", () => { imageOverride: "111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo", imagePullCredentialsTypeOverride: "CODEBUILD", + artifactsTypeOverride: "NO_ARTIFACTS", }); expect(test).to.haveOwnProperty("projectName").and.to.equal(projectName); expect(test).to.haveOwnProperty("sourceVersion").and.to.equal(sha);