Skip to content

Commit 8802399

Browse files
authored
Merge pull request #144 from benconnito/main
allow artifacts type to be overridden
2 parents 6e37b5c + d8df16c commit 8802399

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ inputs:
4343
disable-github-env-vars:
4444
description: 'Set to `true` if you want do disable github environment variables in codebuild'
4545
required: false
46+
artifacts-type-override:
47+
description: 'The type of build output artifact'
48+
required: false
4649
outputs:
4750
aws-build-id:
4851
description: 'The AWS CodeBuild Build ID for this build.'

code-build.js

+14
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ function githubInputs() {
223223
const disableGithubEnvVars =
224224
core.getInput("disable-github-env-vars", { required: false }) === "true";
225225

226+
const artifactsTypeOverride =
227+
core.getInput("artifacts-type-override", { required: false }) || undefined;
228+
226229
return {
227230
projectName,
228231
owner,
@@ -239,6 +242,7 @@ function githubInputs() {
239242
disableSourceOverride,
240243
hideCloudWatchLogs,
241244
disableGithubEnvVars,
245+
artifactsTypeOverride,
242246
};
243247
}
244248

@@ -256,6 +260,7 @@ function inputs2Parameters(inputs) {
256260
envPassthrough = [],
257261
disableSourceOverride,
258262
disableGithubEnvVars,
263+
artifactsTypeOverride,
259264
} = inputs;
260265

261266
const sourceOverride = !disableSourceOverride
@@ -266,6 +271,14 @@ function inputs2Parameters(inputs) {
266271
}
267272
: {};
268273

274+
const artifactsOverride = artifactsTypeOverride
275+
? {
276+
artifactsOverride: {
277+
type: artifactsTypeOverride,
278+
},
279+
}
280+
: {};
281+
269282
const environmentVariablesOverride = Object.entries(process.env)
270283
.filter(
271284
([key]) =>
@@ -280,6 +293,7 @@ function inputs2Parameters(inputs) {
280293
projectName,
281294
...sourceOverride,
282295
buildspecOverride,
296+
...artifactsOverride,
283297
computeTypeOverride,
284298
environmentTypeOverride,
285299
imageOverride,

dist/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ function githubInputs() {
229229
const disableGithubEnvVars =
230230
core.getInput("disable-github-env-vars", { required: false }) === "true";
231231

232+
const artifactsTypeOverride =
233+
core.getInput("artifacts-type-override", { required: false }) || undefined;
234+
232235
return {
233236
projectName,
234237
owner,
@@ -245,6 +248,7 @@ function githubInputs() {
245248
disableSourceOverride,
246249
hideCloudWatchLogs,
247250
disableGithubEnvVars,
251+
artifactsTypeOverride,
248252
};
249253
}
250254

@@ -262,6 +266,7 @@ function inputs2Parameters(inputs) {
262266
envPassthrough = [],
263267
disableSourceOverride,
264268
disableGithubEnvVars,
269+
artifactsTypeOverride,
265270
} = inputs;
266271

267272
const sourceOverride = !disableSourceOverride
@@ -272,6 +277,14 @@ function inputs2Parameters(inputs) {
272277
}
273278
: {};
274279

280+
const artifactsOverride = artifactsTypeOverride
281+
? {
282+
artifactsOverride: {
283+
type: artifactsTypeOverride,
284+
},
285+
}
286+
: {};
287+
275288
const environmentVariablesOverride = Object.entries(process.env)
276289
.filter(
277290
([key]) =>
@@ -286,6 +299,7 @@ function inputs2Parameters(inputs) {
286299
projectName,
287300
...sourceOverride,
288301
buildspecOverride,
302+
...artifactsOverride,
289303
computeTypeOverride,
290304
environmentTypeOverride,
291305
imageOverride,

test/code-build-test.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe("githubInputs", () => {
102102
process.env[`GITHUB_REPOSITORY`] = repoInfo;
103103
process.env[`GITHUB_SHA`] = sha;
104104

105-
process.env[`INPUT_ENV-VARS-FOR-CODEBUILD`] = `one, two
105+
process.env[`INPUT_ENV-VARS-FOR-CODEBUILD`] = `one, two
106106
, three,
107107
four `;
108108

@@ -296,6 +296,7 @@ describe("inputs2Parameters", () => {
296296
imageOverride:
297297
"111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo",
298298
imagePullCredentialsTypeOverride: "CODEBUILD",
299+
artifactsTypeOverride: "NO_ARTIFACTS",
299300
});
300301
expect(test).to.haveOwnProperty("projectName").and.to.equal(projectName);
301302
expect(test).to.haveOwnProperty("sourceVersion").and.to.equal(sha);
@@ -305,6 +306,10 @@ describe("inputs2Parameters", () => {
305306
expect(test)
306307
.to.haveOwnProperty("sourceLocationOverride")
307308
.and.to.equal(`https://github.com/owner/repo.git`);
309+
expect(test)
310+
.to.haveOwnProperty("artifactsOverride")
311+
.that.has.property("type")
312+
.that.equals("NO_ARTIFACTS");
308313
expect(test)
309314
.to.haveOwnProperty("buildspecOverride")
310315
.and.to.equal(undefined);
@@ -352,7 +357,7 @@ describe("inputs2Parameters", () => {
352357
process.env[`GITHUB_REPOSITORY`] = repoInfo;
353358
process.env[`GITHUB_SHA`] = sha;
354359

355-
process.env[`INPUT_ENV-VARS-FOR-CODEBUILD`] = `one, two
360+
process.env[`INPUT_ENV-VARS-FOR-CODEBUILD`] = `one, two
356361
, three,
357362
four `;
358363

0 commit comments

Comments
 (0)