Skip to content

Commit b277b24

Browse files
committed
Add image-override input to aws-codebuild-run-build action
This commit allows user to start build with image override by passing image-override parameter to the action with desired ECR image URI.
1 parent 95cc38b commit b277b24

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ The only required input is `project-name`.
2222
that CodeBuild requires.
2323
By default, the action uses the buildspec file location
2424
that you configured in the CodeBuild project.
25+
1. **image-override** (optional) :
26+
The name of an image for this build that overrides the one specified
27+
in the build project.
2528
1. **env-vars-for-codebuild** (optional) :
2629
A comma-separated list of the names of environment variables
2730
that the action passes from GitHub Actions to CodeBuild.
@@ -162,6 +165,7 @@ this will overwrite them.
162165
with:
163166
project-name: CodeBuildProjectName
164167
buildspec-override: path/to/buildspec.yaml
168+
image-override: ecr-image-uri
165169
env-vars-for-codebuild: |
166170
custom,
167171
requester,

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ inputs:
1010
buildspec-override:
1111
description: 'Buildspec Override'
1212
required: false
13+
image-override:
14+
description: 'The name of an image for this build that overrides the one specified in the build project.'
15+
required: false
1316
env-vars-for-codebuild:
1417
description: 'Comma separated list of environment variables to send to CodeBuild'
1518
required: false

code-build.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ function githubInputs() {
169169
const buildspecOverride =
170170
core.getInput("buildspec-override", { required: false }) || undefined;
171171

172+
const imageOverride =
173+
core.getInput("image-override", { required: false }) || undefined;
174+
172175
const envPassthrough = core
173176
.getInput("env-vars-for-codebuild", { required: false })
174177
.split(",")
@@ -181,6 +184,7 @@ function githubInputs() {
181184
repo,
182185
sourceVersion,
183186
buildspecOverride,
187+
imageOverride,
184188
envPassthrough,
185189
};
186190
}
@@ -192,6 +196,7 @@ function inputs2Parameters(inputs) {
192196
repo,
193197
sourceVersion,
194198
buildspecOverride,
199+
imageOverride,
195200
envPassthrough = [],
196201
} = inputs;
197202

@@ -212,6 +217,7 @@ function inputs2Parameters(inputs) {
212217
sourceTypeOverride,
213218
sourceLocationOverride,
214219
buildspecOverride,
220+
imageOverride,
215221
environmentVariablesOverride,
216222
};
217223
}

dist/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295409,7 +295409,8 @@ module.exports = /******/ (function (modules, runtime) {
295409295409
assert(sourceVersion, "No source version could be evaluated.");
295410295410
const buildspecOverride =
295411295411
core.getInput("buildspec-override", { required: false }) || undefined;
295412-
295412+
const imageOverride =
295413+
core.getInput("image-override", { required: false }) || undefined;
295413295414
const envPassthrough = core
295414295415
.getInput("env-vars-for-codebuild", { required: false })
295415295416
.split(",")
@@ -295422,6 +295423,7 @@ module.exports = /******/ (function (modules, runtime) {
295422295423
repo,
295423295424
sourceVersion,
295424295425
buildspecOverride,
295426+
imageOverride,
295425295427
envPassthrough,
295426295428
};
295427295429
}
@@ -295433,6 +295435,7 @@ module.exports = /******/ (function (modules, runtime) {
295433295435
repo,
295434295436
sourceVersion,
295435295437
buildspecOverride,
295438+
imageOverride,
295436295439
envPassthrough = [],
295437295440
} = inputs;
295438295441

@@ -295453,6 +295456,7 @@ module.exports = /******/ (function (modules, runtime) {
295453295456
sourceTypeOverride,
295454295457
sourceLocationOverride,
295455295458
buildspecOverride,
295459+
imageOverride,
295456295460
environmentVariablesOverride,
295457295461
};
295458295462
}

local.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const cb = require("./code-build");
88
const assert = require("assert");
99
const yargs = require("yargs");
1010

11-
const { projectName, buildspecOverride, envPassthrough, remote } = yargs
11+
const { projectName, buildspecOverride, imageOverride, envPassthrough, remote } = yargs
1212
.option("project-name", {
1313
alias: "p",
1414
describe: "AWS CodeBuild Project Name",
@@ -20,6 +20,11 @@ const { projectName, buildspecOverride, envPassthrough, remote } = yargs
2020
describe: "Path to buildspec file",
2121
type: "string",
2222
})
23+
.option("image-override", {
24+
alias: "i",
25+
describe: "The name of an image for this build that overrides the one specified in the build project.",
26+
type: "string",
27+
})
2328
.option("env-vars-for-codebuild", {
2429
alias: "e",
2530
describe: "List of environment variables to send to CodeBuild",
@@ -39,6 +44,7 @@ const params = cb.inputs2Parameters({
3944
...githubInfo(remote),
4045
sourceVersion: BRANCH_NAME,
4146
buildspecOverride,
47+
imageOverride,
4248
envPassthrough,
4349
});
4450

test/code-build-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ describe("githubInputs", () => {
7171
expect(test)
7272
.to.haveOwnProperty("buildspecOverride")
7373
.and.to.equal(undefined);
74+
expect(test).to.haveOwnProperty("imageOverride").and.to.equal(undefined);
7475
expect(test).to.haveOwnProperty("envPassthrough").and.to.deep.equal([]);
7576
});
7677

@@ -120,6 +121,7 @@ describe("githubInputs", () => {
120121
expect(test)
121122
.to.haveOwnProperty("buildspecOverride")
122123
.and.to.equal(undefined);
124+
expect(test).to.haveOwnProperty("imageOverride").and.to.equal(undefined);
123125
expect(test).to.haveOwnProperty("envPassthrough").and.to.deep.equal([]);
124126
});
125127

@@ -173,6 +175,7 @@ describe("inputs2Parameters", () => {
173175
expect(test)
174176
.to.haveOwnProperty("buildspecOverride")
175177
.and.to.equal(undefined);
178+
expect(test).to.haveOwnProperty("imageOverride").and.to.equal(undefined);
176179

177180
// I send everything that starts 'GITHUB_'
178181
expect(test)

0 commit comments

Comments
 (0)