Skip to content

Commit

Permalink
Merge pull request #141 from jpaas/fix/140
Browse files Browse the repository at this point in the history
Fixes #140
  • Loading branch information
taoyong-ty authored Sep 26, 2023
2 parents ea7ff88 + c7cf6e3 commit a95fe55
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 4 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ The only required input is `project-name`.
The location (in this repository) of the [buildspec file][codebuild buildspec]
that CodeBuild requires.
By default, the action uses the buildspec file location
that you configured in the CodeBuild project.
that you configured in the CodeBuild project.

Alternatively, you can pass in an inline buildspec definition like so:

```
Expand Down Expand Up @@ -50,13 +50,14 @@ The only required input is `project-name`.
- npm prune --production
post_build:
commands:
- echo Build completed on `date`
- echo Build completed on `date`
artifacts:
type: zip
files:
- package.json
- package-lock.json
```

1. **compute-type-override** (optional) :
The name of a compute type for this build that overrides the one specified
in the build project.
Expand All @@ -66,6 +67,8 @@ The only required input is `project-name`.
1. **image-override** (optional) :
The name of an image for this build that overrides the one specified
in the build project.
1. **image-pull-credentials-type-override** (optional) :
The type of credentials CodeBuild uses to pull images in your build.
1. **disable-source-override** (optional) :
Set to `true` if you want to disable providing `sourceVersion`,
`sourceTypeOverride` and `sourceLocationOverride` to CodeBuild.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
image-override:
description: 'The name of an image for this build that overrides the one specified in the build project.'
required: false
image-pull-credentials-type-override:
description: 'The type of credentials CodeBuild uses to pull images in your build.'
required: false
env-vars-for-codebuild:
description: 'Comma separated list of environment variables to send to CodeBuild'
required: false
Expand Down
9 changes: 9 additions & 0 deletions code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,15 @@ function githubInputs() {
const environmentTypeOverride =
core.getInput("environment-type-override", { required: false }) ||
undefined;

const imageOverride =
core.getInput("image-override", { required: false }) || undefined;

const imagePullCredentialsTypeOverride =
core.getInput("image-pull-credentials-type-override", {
required: false,
}) || undefined;

const envPassthrough = core
.getInput("env-vars-for-codebuild", { required: false })
.split(",")
Expand Down Expand Up @@ -225,6 +231,7 @@ function githubInputs() {
computeTypeOverride,
environmentTypeOverride,
imageOverride,
imagePullCredentialsTypeOverride,
envPassthrough,
updateInterval,
updateBackOff,
Expand All @@ -244,6 +251,7 @@ function inputs2Parameters(inputs) {
computeTypeOverride,
environmentTypeOverride,
imageOverride,
imagePullCredentialsTypeOverride,
envPassthrough = [],
disableSourceOverride,
disableGithubEnvVars,
Expand Down Expand Up @@ -274,6 +282,7 @@ function inputs2Parameters(inputs) {
computeTypeOverride,
environmentTypeOverride,
imageOverride,
imagePullCredentialsTypeOverride,
environmentVariablesOverride,
};
}
Expand Down
9 changes: 9 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,15 @@ function githubInputs() {
const environmentTypeOverride =
core.getInput("environment-type-override", { required: false }) ||
undefined;

const imageOverride =
core.getInput("image-override", { required: false }) || undefined;

const imagePullCredentialsTypeOverride =
core.getInput("image-pull-credentials-type-override", {
required: false,
}) || undefined;

const envPassthrough = core
.getInput("env-vars-for-codebuild", { required: false })
.split(",")
Expand Down Expand Up @@ -231,6 +237,7 @@ function githubInputs() {
computeTypeOverride,
environmentTypeOverride,
imageOverride,
imagePullCredentialsTypeOverride,
envPassthrough,
updateInterval,
updateBackOff,
Expand All @@ -250,6 +257,7 @@ function inputs2Parameters(inputs) {
computeTypeOverride,
environmentTypeOverride,
imageOverride,
imagePullCredentialsTypeOverride,
envPassthrough = [],
disableSourceOverride,
disableGithubEnvVars,
Expand Down Expand Up @@ -280,6 +288,7 @@ function inputs2Parameters(inputs) {
computeTypeOverride,
environmentTypeOverride,
imageOverride,
imagePullCredentialsTypeOverride,
environmentVariablesOverride,
};
}
Expand Down
10 changes: 9 additions & 1 deletion local.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const {
computeTypeOverride,
environmentTypeOverride,
imageOverride,
imagePullCredentialsTypeOverride,
envPassthrough,
remote,
updateInterval,
Expand Down Expand Up @@ -45,9 +46,15 @@ const {
.option("image-override", {
alias: "i",
describe:
"The name of an image for this build that overrides the one specified in the build project.",
"The type of credentials CodeBuild uses to pull images in your build.",
type: "string",
})
.option("image-pull-credentials-type-override", {
alias: "it",
describe:
"The name of an image for this build that overrides the one specified in the build project.",
choices: ["CODEBUILD", "SERVICE_ROLE"],
})
.option("env-vars-for-codebuild", {
alias: "e",
describe: "List of environment variables to send to CodeBuild",
Expand Down Expand Up @@ -81,6 +88,7 @@ const params = cb.inputs2Parameters({
computeTypeOverride,
environmentTypeOverride,
imageOverride,
imagePullCredentialsTypeOverride,
envPassthrough,
});

Expand Down
13 changes: 13 additions & 0 deletions test/code-build-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ describe("githubInputs", () => {
.to.haveOwnProperty("environmentTypeOverride")
.and.to.equal(undefined);
expect(test).to.haveOwnProperty("imageOverride").and.to.equal(undefined);
expect(test)
.to.haveOwnProperty("imagePullCredentialsTypeOverride")
.and.to.equal(undefined);
expect(test).to.haveOwnProperty("envPassthrough").and.to.deep.equal([]);
expect(test).to.haveOwnProperty("hideCloudWatchLogs").and.to.equal(false);
expect(test).to.haveOwnProperty("disableGithubEnvVars").and.to.equal(false);
Expand Down Expand Up @@ -156,6 +159,9 @@ describe("githubInputs", () => {
.to.haveOwnProperty("environmentTypeOverride")
.and.to.equal(undefined);
expect(test).to.haveOwnProperty("imageOverride").and.to.equal(undefined);
expect(test)
.to.haveOwnProperty("imagePullCredentialsTypeOverride")
.and.to.equal(undefined);
expect(test).to.haveOwnProperty("envPassthrough").and.to.deep.equal([]);
});

Expand Down Expand Up @@ -248,6 +254,9 @@ describe("inputs2Parameters", () => {
.to.haveOwnProperty("environmentTypeOverride")
.and.to.equal(undefined);
expect(test).to.haveOwnProperty("imageOverride").and.to.equal(undefined);
expect(test)
.to.haveOwnProperty("imagePullCredentialsTypeOverride")
.and.to.equal(undefined);

// I send everything that starts 'GITHUB_'
expect(test)
Expand Down Expand Up @@ -286,6 +295,7 @@ describe("inputs2Parameters", () => {
environmentTypeOverride: "LINUX_CONTAINER",
imageOverride:
"111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo",
imagePullCredentialsTypeOverride: "CODEBUILD",
});
expect(test).to.haveOwnProperty("projectName").and.to.equal(projectName);
expect(test).to.haveOwnProperty("sourceVersion").and.to.equal(sha);
Expand All @@ -309,6 +319,9 @@ describe("inputs2Parameters", () => {
.and.to.equal(
`111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo`
);
expect(test)
.to.haveOwnProperty("imagePullCredentialsTypeOverride")
.and.to.equal(`CODEBUILD`);

// I send everything that starts 'GITHUB_'
expect(test)
Expand Down

0 comments on commit a95fe55

Please sign in to comment.