Skip to content

Commit

Permalink
add artifacts-type-override to action.yml to specify the artifact typ…
Browse files Browse the repository at this point in the history
…e override
  • Loading branch information
benconnito committed Oct 1, 2023
1 parent fd063b3 commit 620558a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
15 changes: 13 additions & 2 deletions code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -238,6 +241,7 @@ function githubInputs() {
disableSourceOverride,
hideCloudWatchLogs,
disableGithubEnvVars,
artifactsTypeOverride,
};
}

Expand All @@ -255,6 +259,7 @@ function inputs2Parameters(inputs) {
envPassthrough = [],
disableSourceOverride,
disableGithubEnvVars,
artifactsTypeOverride,
} = inputs;

const sourceOverride = !disableSourceOverride
Expand All @@ -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(
Expand All @@ -281,7 +292,7 @@ function inputs2Parameters(inputs) {
projectName,
...sourceOverride,
buildspecOverride,
artifactsOverride,
...artifactsOverride,
computeTypeOverride,
environmentTypeOverride,
imageOverride,
Expand Down
15 changes: 13 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -244,6 +247,7 @@ function githubInputs() {
disableSourceOverride,
hideCloudWatchLogs,
disableGithubEnvVars,
artifactsTypeOverride,
};
}

Expand All @@ -261,6 +265,7 @@ function inputs2Parameters(inputs) {
envPassthrough = [],
disableSourceOverride,
disableGithubEnvVars,
artifactsTypeOverride,
} = inputs;

const sourceOverride = !disableSourceOverride
Expand All @@ -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(
Expand All @@ -287,7 +298,7 @@ function inputs2Parameters(inputs) {
projectName,
...sourceOverride,
buildspecOverride,
artifactsOverride,
...artifactsOverride,
computeTypeOverride,
environmentTypeOverride,
imageOverride,
Expand Down
5 changes: 1 addition & 4 deletions test/code-build-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 620558a

Please sign in to comment.