Skip to content

Commit

Permalink
Merge pull request #102 from marcus-bcl/master
Browse files Browse the repository at this point in the history
Support Disabling Source Type Override Parameters, including Source Version
  • Loading branch information
taoyong-ty authored Feb 9, 2023
2 parents 355b7af + ec9d780 commit 7d9ae4e
Show file tree
Hide file tree
Showing 6 changed files with 62,379 additions and 69,440 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ 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. **disable-source-override** (optional) :
Set to `true` if you want to disable providing `sourceVersion`,
`sourceTypeOverride` and `sourceLocationOverride` 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 Expand Up @@ -247,7 +250,7 @@ In the call to StartBuild, we pass in all
`GITHUB_` [environment variables][github environment variables] in the GitHub Actions environment,
plus any environment variables that you specified in the `env-passthrough` input value.
Regardless of the project configuration in CodeBuild or GitHub Actions,
By default, regardless of the project configuration in CodeBuild or GitHub Actions,
we always pass the following parameters and values to CodeBuild in the StartBuild API call.
| CodeBuild value | GitHub value |
Expand All @@ -256,6 +259,8 @@ we always pass the following parameters and values to CodeBuild in the StartBuil
| `sourceTypeOverride` | The string `'GITHUB'` |
| `sourceLocationOverride` | The `HTTPS` git url for `context.repo` |
If you want to disable sending the parameters `sourceVersion`, `sourceTypeOverride` and `sourceLocationOverride` you can use `disable-source-override` input.
### What we did not do
This action intentionally does not let you specify every option
Expand Down
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ inputs:
update-back-off:
description: 'Base back-off time for the update calls for API if rate-limiting is encountered'
required: false

disable-source-override:
description: 'Set to `true` if you want do disable source repo override'
required: false
outputs:
aws-build-id:
description: 'The AWS CodeBuild Build ID for this build.'
Expand Down
18 changes: 13 additions & 5 deletions code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ async function waitForBuildEndTime(

function githubInputs() {
const projectName = core.getInput("project-name", { required: true });
const disableSourceOverride =
core.getInput("disable-source-override", { required: false }) === "true";
const { owner, repo } = github.context.repo;
const { payload } = github.context;
// The github.context.sha is evaluated on import.
Expand Down Expand Up @@ -220,6 +222,7 @@ function githubInputs() {
envPassthrough,
updateInterval,
updateBackOff,
disableSourceOverride,
};
}

Expand All @@ -234,10 +237,16 @@ function inputs2Parameters(inputs) {
environmentTypeOverride,
imageOverride,
envPassthrough = [],
disableSourceOverride,
} = inputs;

const sourceTypeOverride = "GITHUB";
const sourceLocationOverride = `https://github.com/${owner}/${repo}.git`;
const sourceOverride = !disableSourceOverride
? {
sourceVersion: sourceVersion,
sourceTypeOverride: "GITHUB",
sourceLocationOverride: `https://github.com/${owner}/${repo}.git`,
}
: {};

const environmentVariablesOverride = Object.entries(process.env)
.filter(
Expand All @@ -249,14 +258,13 @@ function inputs2Parameters(inputs) {
// This way the GitHub events can manage the builds.
return {
projectName,
sourceVersion,
sourceTypeOverride,
sourceLocationOverride,
...sourceOverride,
buildspecOverride,
computeTypeOverride,
environmentTypeOverride,
imageOverride,
environmentVariablesOverride,
disableSourceOverride,
};
}

Expand Down
Loading

0 comments on commit 7d9ae4e

Please sign in to comment.