Skip to content

Commit 7d9ae4e

Browse files
authored
Merge pull request #102 from marcus-bcl/master
Support Disabling Source Type Override Parameters, including Source Version
2 parents 355b7af + ec9d780 commit 7d9ae4e

File tree

6 files changed

+62379
-69440
lines changed

6 files changed

+62379
-69440
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ The only required input is `project-name`.
3131
1. **image-override** (optional) :
3232
The name of an image for this build that overrides the one specified
3333
in the build project.
34+
1. **disable-source-override** (optional) :
35+
Set to `true` if you want to disable providing `sourceVersion`,
36+
`sourceTypeOverride` and `sourceLocationOverride` to CodeBuild.
3437
1. **env-vars-for-codebuild** (optional) :
3538
A comma-separated list of the names of environment variables
3639
that the action passes from GitHub Actions to CodeBuild.
@@ -247,7 +250,7 @@ In the call to StartBuild, we pass in all
247250
`GITHUB_` [environment variables][github environment variables] in the GitHub Actions environment,
248251
plus any environment variables that you specified in the `env-passthrough` input value.
249252
250-
Regardless of the project configuration in CodeBuild or GitHub Actions,
253+
By default, regardless of the project configuration in CodeBuild or GitHub Actions,
251254
we always pass the following parameters and values to CodeBuild in the StartBuild API call.
252255
253256
| CodeBuild value | GitHub value |
@@ -256,6 +259,8 @@ we always pass the following parameters and values to CodeBuild in the StartBuil
256259
| `sourceTypeOverride` | The string `'GITHUB'` |
257260
| `sourceLocationOverride` | The `HTTPS` git url for `context.repo` |
258261
262+
If you want to disable sending the parameters `sourceVersion`, `sourceTypeOverride` and `sourceLocationOverride` you can use `disable-source-override` input.
263+
259264
### What we did not do
260265
261266
This action intentionally does not let you specify every option

action.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ inputs:
2828
update-back-off:
2929
description: 'Base back-off time for the update calls for API if rate-limiting is encountered'
3030
required: false
31-
31+
disable-source-override:
32+
description: 'Set to `true` if you want do disable source repo override'
33+
required: false
3234
outputs:
3335
aws-build-id:
3436
description: 'The AWS CodeBuild Build ID for this build.'

code-build.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ async function waitForBuildEndTime(
165165

166166
function githubInputs() {
167167
const projectName = core.getInput("project-name", { required: true });
168+
const disableSourceOverride =
169+
core.getInput("disable-source-override", { required: false }) === "true";
168170
const { owner, repo } = github.context.repo;
169171
const { payload } = github.context;
170172
// The github.context.sha is evaluated on import.
@@ -220,6 +222,7 @@ function githubInputs() {
220222
envPassthrough,
221223
updateInterval,
222224
updateBackOff,
225+
disableSourceOverride,
223226
};
224227
}
225228

@@ -234,10 +237,16 @@ function inputs2Parameters(inputs) {
234237
environmentTypeOverride,
235238
imageOverride,
236239
envPassthrough = [],
240+
disableSourceOverride,
237241
} = inputs;
238242

239-
const sourceTypeOverride = "GITHUB";
240-
const sourceLocationOverride = `https://github.com/${owner}/${repo}.git`;
243+
const sourceOverride = !disableSourceOverride
244+
? {
245+
sourceVersion: sourceVersion,
246+
sourceTypeOverride: "GITHUB",
247+
sourceLocationOverride: `https://github.com/${owner}/${repo}.git`,
248+
}
249+
: {};
241250

242251
const environmentVariablesOverride = Object.entries(process.env)
243252
.filter(
@@ -249,14 +258,13 @@ function inputs2Parameters(inputs) {
249258
// This way the GitHub events can manage the builds.
250259
return {
251260
projectName,
252-
sourceVersion,
253-
sourceTypeOverride,
254-
sourceLocationOverride,
261+
...sourceOverride,
255262
buildspecOverride,
256263
computeTypeOverride,
257264
environmentTypeOverride,
258265
imageOverride,
259266
environmentVariablesOverride,
267+
disableSourceOverride,
260268
};
261269
}
262270

0 commit comments

Comments
 (0)