Skip to content

Disabled GITHUB Envs being passed to Codebuild #142

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

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ The only required input is `project-name`.
1. **hide-cloudwatch-logs** (optional) :
Set to `true` if you do not want CloudWatch Logs to be streamed to GitHub Action.

1. **disable-github-env-vars** (optional) :
Set to `true` if you want do disable github environment variables in codebuild.

### Outputs

1. **aws-build-id** : The CodeBuild build ID of the build that the action ran.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ inputs:
hide-cloudwatch-logs:
description: 'Set to `true` to prevent the CloudWatch logs from streaming the output to GitHub'
required: false
disable-github-env-vars:
description: 'Set to `true` if you want do disable github environment variables in codebuild'
required: false
outputs:
aws-build-id:
description: 'The AWS CodeBuild Build ID for this build.'
Expand Down
9 changes: 8 additions & 1 deletion code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ function githubInputs() {
const hideCloudWatchLogs =
core.getInput("hide-cloudwatch-logs", { required: false }) === "true";

const disableGithubEnvVars =
core.getInput("disable-github-env-vars", { required: false }) === "true";

return {
projectName,
owner,
Expand All @@ -227,6 +230,7 @@ function githubInputs() {
updateBackOff,
disableSourceOverride,
hideCloudWatchLogs,
disableGithubEnvVars,
};
}

Expand All @@ -242,6 +246,7 @@ function inputs2Parameters(inputs) {
imageOverride,
envPassthrough = [],
disableSourceOverride,
disableGithubEnvVars,
} = inputs;

const sourceOverride = !disableSourceOverride
Expand All @@ -254,7 +259,9 @@ function inputs2Parameters(inputs) {

const environmentVariablesOverride = Object.entries(process.env)
.filter(
([key]) => key.startsWith("GITHUB_") || envPassthrough.includes(key)
([key]) =>
(!disableGithubEnvVars && key.startsWith("GITHUB_")) ||
envPassthrough.includes(key)
)
.map(([name, value]) => ({ name, value, type: "PLAINTEXT" }));

Expand Down
Loading