Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Disabling Source Type Override Parameters, including Source Version #102

Merged
merged 9 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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. **disable-source-override** (optional) :
Set to `true` if you want to disable providing `sourceTypeOverride` and `sourceLocationOverride` to CodeBuild.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and sourceVersion

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 @@ -222,7 +224,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 `evn-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 @@ -231,6 +233,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
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ inputs:
env-vars-for-codebuild:
description: 'Comma separated list of environment variables to send to CodeBuild'
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
17 changes: 12 additions & 5 deletions code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ async function waitForBuildEndTime(

function githubInputs() {
const projectName = core.getInput("project-name", { required: true });
const disableSourceOverride =
core.getInput("disable-source-override") === "true";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, could you either update this new line to use core.getInput("disable-source-override", {required: false}) === "true", or remove all other { required: false }s from githubInputs()?

const { owner, repo } = github.context.repo;
const { payload } = github.context;
// The github.context.sha is evaluated on import.
Expand Down Expand Up @@ -193,6 +195,7 @@ function githubInputs() {
environmentTypeOverride,
imageOverride,
envPassthrough,
disableSourceOverride,
};
}

Expand All @@ -207,10 +210,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 @@ -222,9 +231,7 @@ function inputs2Parameters(inputs) {
// This way the GitHub events can manage the builds.
return {
projectName,
sourceVersion,
sourceTypeOverride,
sourceLocationOverride,
...sourceOverride,
buildspecOverride,
computeTypeOverride,
environmentTypeOverride,
Expand Down
Loading