Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ The only required input is `project-name`.
`sourceTypeOverride` and `sourceLocationOverride` to CodeBuild.
1. **source-version-override** (optional) :
The source version that overrides the `sourceVersion` provided to Codebuild.
1. **source-type-override** (optional) :
The source type that overrides the `sourceTypeOverride` provided to Codebuild.
1. **source-location-override** (optional) :
The source location that overrides the `sourceLocationOverride` provided to Codebuild.
1. **env-vars-for-codebuild** (optional) :
A comma-separated list of the names of environment variables
that the action passes from GitHub Actions to CodeBuild.
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ inputs:
source-version-override:
description: 'The source version that overrides the sourceVersion provided to Codebuild.'
required: false
source-type-override:
description: 'The source input type that overrides the source input defined in the build project for this build. Valid values include NO_SOURCE, CODECOMMIT, CODEPIPELINE, GITHUB, S3, BITBUCKET, and GITHUB_ENTERPRISE.'
required: false
source-location-override:
description: 'The location that overrides the source location defined in the build project for this build.'
required: false
hide-cloudwatch-logs:
description: 'Set to `true` to prevent the CloudWatch logs from streaming the output to GitHub'
required: false
Expand Down
15 changes: 13 additions & 2 deletions code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ function githubInputs() {
: process.env[`GITHUB_SHA`]);

assert(sourceVersion, "No source version could be evaluated.");

const sourceTypeOverride =
core.getInput("source-type-override", { required: false, }) || undefined;

const sourceLocationOverride =
core.getInput("source-location-override", { required: false }) || undefined;

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

Expand Down Expand Up @@ -260,6 +267,8 @@ function githubInputs() {
owner,
repo,
sourceVersion,
sourceTypeOverride,
sourceLocationOverride,
buildspecOverride,
computeTypeOverride,
environmentTypeOverride,
Expand All @@ -282,6 +291,8 @@ function inputs2Parameters(inputs) {
owner,
repo,
sourceVersion,
sourceTypeOverride,
sourceLocationOverride,
buildspecOverride,
computeTypeOverride,
environmentTypeOverride,
Expand All @@ -296,8 +307,8 @@ function inputs2Parameters(inputs) {
const sourceOverride = !disableSourceOverride
? {
sourceVersion: sourceVersion,
sourceTypeOverride: "GITHUB",
sourceLocationOverride: `https://github.com/${owner}/${repo}.git`,
sourceTypeOverride: sourceTypeOverride || "GITHUB",
sourceLocationOverride: sourceLocationOverride || `https://github.com/${owner}/${repo}.git`,
}
: {};

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 @@ -420,6 +420,19 @@ describe("inputs2Parameters", () => {
expect(test).to.not.haveOwnProperty("sourceVersion");
});

it("can process source-type-override and source-location-override", () => {
const test = inputs2Parameters({
projectName,
sourceVersion: sha,
owner: "owner",
repo: "repo",
sourceTypeOverride: "S3",
sourceLocationOverride: "bucket-name/object-name",
});
expect(test).to.haveOwnProperty("sourceTypeOverride").and.to.equal("S3");
expect(test).to.haveOwnProperty("sourceLocationOverride").and.to.equal("bucket-name/object-name");
});

it("can process disable-github-env-vars", () => {
process.env[`GITHUB_REPOSITORY`] = repoInfo;
process.env[`GITHUB_SHA`] = sha;
Expand Down