From 6f9f7e153a26b268d140138a949227114997267c Mon Sep 17 00:00:00 2001 From: yamao-latte Date: Sun, 28 Apr 2024 18:48:51 +0900 Subject: [PATCH] feat: Add support for sourceTypeOverride and sourceLocationOverride This commit introduces two new optional parameters: sourceTypeOverride: Allows overriding the source input type defined in the build project for the current build. Valid values include NO_SOURCE, CODECOMMIT, CODEPIPELINE, GITHUB, S3, BITBUCKET, and GITHUB_ENTERPRISE. sourceLocationOverride: Enables specifying a location that overrides the source location defined in the build project for the current build. These parameters provide flexibility in customizing the source settings for individual builds, without modifying the underlying build project configuration. --- README.md | 4 ++++ action.yml | 6 ++++++ code-build.js | 13 +++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a12e20e..bdf7f3b 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ The only required input is `project-name`. `sourceTypeOverride` and `sourceLocationOverride` to CodeBuild. 1. **source-version-override** (optional) : The source version that overrides the `sourceVersion` provided to Codebuild. +1. **source-type-override** (optional) : + The source type that overrides the `sourceTypeOverride` provided to Codebuild. +1. **source-location-override** (optional) : + The source location that overrides the `sourceLocationOverride` provided 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. diff --git a/action.yml b/action.yml index d702109..5523bf6 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,12 @@ inputs: source-version-override: description: 'The source version that overrides the sourceVersion provided to Codebuild.' required: false + source-type-override: + 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.' + required: false + source-location-override: + description: 'The location that overrides the source location defined in the build project for this build.' + required: false hide-cloudwatch-logs: description: 'Set to `true` to prevent the CloudWatch logs from streaming the output to GitHub' required: false diff --git a/code-build.js b/code-build.js index 8c7f6ff..519c9b4 100644 --- a/code-build.js +++ b/code-build.js @@ -205,6 +205,13 @@ function githubInputs() { : process.env[`GITHUB_SHA`]); assert(sourceVersion, "No source version could be evaluated."); + + const sourceTypeOverride = + core.getInput("source-type-override", { required: false, }) || undefined; + + const sourceLocationOverride = + core.getInput("source-location-override", { required: false }) || undefined; + const buildspecOverride = core.getInput("buildspec-override", { required: false }) || undefined; @@ -282,6 +289,8 @@ function inputs2Parameters(inputs) { owner, repo, sourceVersion, + sourceTypeOverride, + sourceLocationOverride, buildspecOverride, computeTypeOverride, environmentTypeOverride, @@ -296,8 +305,8 @@ function inputs2Parameters(inputs) { const sourceOverride = !disableSourceOverride ? { sourceVersion: sourceVersion, - sourceTypeOverride: "GITHUB", - sourceLocationOverride: `https://github.com/${owner}/${repo}.git`, + sourceTypeOverride: sourceTypeOverride || "GITHUB", + sourceLocationOverride: sourceLocationOverride || `https://github.com/${owner}/${repo}.git`, } : {};