Skip to content

Commit 287d617

Browse files
authored
Merge pull request #165 from yamao-latte/feature/support-github-enterprise-source
feat: Add support for sourceTypeOverride and sourceLocationOverride
2 parents adc39f2 + 37a96a5 commit 287d617

File tree

6 files changed

+25647
-30604
lines changed

6 files changed

+25647
-30604
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ The only required input is `project-name`.
7676
`sourceTypeOverride` and `sourceLocationOverride` to CodeBuild.
7777
1. **source-version-override** (optional) :
7878
The source version that overrides the `sourceVersion` provided to Codebuild.
79+
1. **source-type-override** (optional) :
80+
The source type that overrides the `sourceTypeOverride` provided to Codebuild.
81+
1. **source-location-override** (optional) :
82+
The source location that overrides the `sourceLocationOverride` provided to Codebuild.
7983
1. **env-vars-for-codebuild** (optional) :
8084
A comma-separated list of the names of environment variables
8185
that the action passes from GitHub Actions to CodeBuild.

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ inputs:
3737
source-version-override:
3838
description: 'The source version that overrides the sourceVersion provided to Codebuild.'
3939
required: false
40+
source-type-override:
41+
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.'
42+
required: false
43+
source-location-override:
44+
description: 'The location that overrides the source location defined in the build project for this build.'
45+
required: false
4046
hide-cloudwatch-logs:
4147
description: 'Set to `true` to prevent the CloudWatch logs from streaming the output to GitHub'
4248
required: false

code-build.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ function githubInputs() {
205205
: process.env[`GITHUB_SHA`]);
206206

207207
assert(sourceVersion, "No source version could be evaluated.");
208+
209+
const sourceTypeOverride =
210+
core.getInput("source-type-override", { required: false, }) || undefined;
211+
212+
const sourceLocationOverride =
213+
core.getInput("source-location-override", { required: false }) || undefined;
214+
208215
const buildspecOverride =
209216
core.getInput("buildspec-override", { required: false }) || undefined;
210217

@@ -260,6 +267,8 @@ function githubInputs() {
260267
owner,
261268
repo,
262269
sourceVersion,
270+
sourceTypeOverride,
271+
sourceLocationOverride,
263272
buildspecOverride,
264273
computeTypeOverride,
265274
environmentTypeOverride,
@@ -282,6 +291,8 @@ function inputs2Parameters(inputs) {
282291
owner,
283292
repo,
284293
sourceVersion,
294+
sourceTypeOverride,
295+
sourceLocationOverride,
285296
buildspecOverride,
286297
computeTypeOverride,
287298
environmentTypeOverride,
@@ -295,9 +306,12 @@ function inputs2Parameters(inputs) {
295306

296307
const sourceOverride = !disableSourceOverride
297308
? {
298-
sourceVersion: sourceVersion,
299-
sourceTypeOverride: "GITHUB",
300-
sourceLocationOverride: `https://github.com/${owner}/${repo}.git`,
309+
// sourceVersion should not be set when using sourceTypeOverride or sourceLocationOverride
310+
...(sourceTypeOverride || sourceLocationOverride
311+
? {}
312+
: {sourceVersion}),
313+
sourceTypeOverride: sourceTypeOverride || "GITHUB",
314+
sourceLocationOverride: sourceLocationOverride || `https://github.com/${owner}/${repo}.git`,
301315
}
302316
: {};
303317

0 commit comments

Comments
 (0)