From 0b644b3ba7f44c80cb4e9eb153ddd9b9fcadf61a Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Sep 2024 12:59:05 +0200 Subject: [PATCH] Add oidc-only flag --- action.yml | 4 ++++ lib/main.js | 9 +++++++-- lib/utils.js | 2 ++ src/main.ts | 8 ++++++-- src/utils.ts | 2 ++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index eab8b4f86..ce93cecb2 100644 --- a/action.yml +++ b/action.yml @@ -15,6 +15,10 @@ inputs: oidc-audience: description: "By default, this is the URL of the GitHub repository owner, such as the organization that owns the repository." required: false + oidc-only: + description: "Set to true to only authenticate using OIDC and not set up JFrog CLI." + default: "false" + required: false disable-job-summary: description: "Set to true to disable the generation of Job Summaries." default: "false" diff --git a/lib/main.js b/lib/main.js index 1f05b710f..6f36b4455 100644 --- a/lib/main.js +++ b/lib/main.js @@ -40,8 +40,13 @@ function main() { core.startGroup('Setup JFrog CLI'); utils_1.Utils.setCliEnv(); let jfrogCredentials = yield utils_1.Utils.getJfrogCredentials(); - yield utils_1.Utils.getAndAddCliToPath(jfrogCredentials); - yield utils_1.Utils.configJFrogServers(jfrogCredentials); + if (core.getInput(utils_1.Utils.OIDC_ONLY) !== 'true') { + yield utils_1.Utils.getAndAddCliToPath(jfrogCredentials); + yield utils_1.Utils.configJFrogServers(jfrogCredentials); + } + else { + core.debug('Skipping JFrog CLI setup as oidc-only is enabled.'); + } } catch (error) { core.setFailed(error.message); diff --git a/lib/utils.js b/lib/utils.js index 1a05f5af5..e8662b8bd 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -742,6 +742,8 @@ Utils.CLI_REMOTE_ARG = 'download-repository'; Utils.OIDC_AUDIENCE_ARG = 'oidc-audience'; // OpenID Connect provider_name input Utils.OIDC_INTEGRATION_PROVIDER_NAME = 'oidc-provider-name'; +// Whether to skip JFrog CLI setup and only use OIDC +Utils.OIDC_ONLY = 'oidc-only'; // Disable Job Summaries feature flag Utils.JOB_SUMMARY_DISABLE = 'disable-job-summary'; // Disable auto build info publish feature flag diff --git a/src/main.ts b/src/main.ts index 299c2eb87..29629c2f3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,8 +6,12 @@ async function main() { core.startGroup('Setup JFrog CLI'); Utils.setCliEnv(); let jfrogCredentials: JfrogCredentials = await Utils.getJfrogCredentials(); - await Utils.getAndAddCliToPath(jfrogCredentials); - await Utils.configJFrogServers(jfrogCredentials); + if (core.getInput(Utils.OIDC_ONLY) !== 'true') { + await Utils.getAndAddCliToPath(jfrogCredentials); + await Utils.configJFrogServers(jfrogCredentials); + } else { + core.debug('Skipping JFrog CLI setup as oidc-only is enabled.'); + } } catch (error) { core.setFailed((error).message); } finally { diff --git a/src/utils.ts b/src/utils.ts index c92ef1524..6878c005b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -57,6 +57,8 @@ export class Utils { private static readonly OIDC_AUDIENCE_ARG: string = 'oidc-audience'; // OpenID Connect provider_name input private static readonly OIDC_INTEGRATION_PROVIDER_NAME: string = 'oidc-provider-name'; + // Whether to skip JFrog CLI setup and only use OIDC + public static readonly OIDC_ONLY: string = 'oidc-only'; // Disable Job Summaries feature flag public static readonly JOB_SUMMARY_DISABLE: string = 'disable-job-summary'; // Disable auto build info publish feature flag