diff --git a/README.md b/README.md index 3331c80..167f9a5 100644 --- a/README.md +++ b/README.md @@ -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: ``` @@ -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. @@ -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. diff --git a/action.yml b/action.yml index c3f354b..054be7b 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/code-build.js b/code-build.js index ead7a27..7003807 100644 --- a/code-build.js +++ b/code-build.js @@ -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(",") @@ -225,6 +231,7 @@ function githubInputs() { computeTypeOverride, environmentTypeOverride, imageOverride, + imagePullCredentialsTypeOverride, envPassthrough, updateInterval, updateBackOff, @@ -244,6 +251,7 @@ function inputs2Parameters(inputs) { computeTypeOverride, environmentTypeOverride, imageOverride, + imagePullCredentialsTypeOverride, envPassthrough = [], disableSourceOverride, disableGithubEnvVars, @@ -274,6 +282,7 @@ function inputs2Parameters(inputs) { computeTypeOverride, environmentTypeOverride, imageOverride, + imagePullCredentialsTypeOverride, environmentVariablesOverride, }; } diff --git a/dist/index.js b/dist/index.js index e94ee8c..6a486d5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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(",") @@ -231,6 +237,7 @@ function githubInputs() { computeTypeOverride, environmentTypeOverride, imageOverride, + imagePullCredentialsTypeOverride, envPassthrough, updateInterval, updateBackOff, @@ -250,6 +257,7 @@ function inputs2Parameters(inputs) { computeTypeOverride, environmentTypeOverride, imageOverride, + imagePullCredentialsTypeOverride, envPassthrough = [], disableSourceOverride, disableGithubEnvVars, @@ -280,6 +288,7 @@ function inputs2Parameters(inputs) { computeTypeOverride, environmentTypeOverride, imageOverride, + imagePullCredentialsTypeOverride, environmentVariablesOverride, }; } diff --git a/local.js b/local.js index dd1a255..6d7d6c2 100644 --- a/local.js +++ b/local.js @@ -14,6 +14,7 @@ const { computeTypeOverride, environmentTypeOverride, imageOverride, + imagePullCredentialsTypeOverride, envPassthrough, remote, updateInterval, @@ -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", @@ -81,6 +88,7 @@ const params = cb.inputs2Parameters({ computeTypeOverride, environmentTypeOverride, imageOverride, + imagePullCredentialsTypeOverride, envPassthrough, }); diff --git a/test/code-build-test.js b/test/code-build-test.js index 26eb823..cb41bfa 100644 --- a/test/code-build-test.js +++ b/test/code-build-test.js @@ -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); @@ -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([]); }); @@ -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) @@ -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); @@ -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)