File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed
Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,13 @@ class Utils {
281281 }
282282 static configJFrogServers ( jfrogCredentials ) {
283283 return __awaiter ( this , void 0 , void 0 , function * ( ) {
284- let cliConfigCmd = [ 'config' ] ;
284+ let cliConfigCmd = [ ] ;
285+ let githubToken = jfrogCredentials . githubToken ;
286+ if ( ! ! githubToken ) {
287+ // Github Token
288+ cliConfigCmd = cliConfigCmd . concat ( '--github-token' , githubToken ) ;
289+ }
290+ cliConfigCmd = cliConfigCmd . concat ( 'config' ) ;
285291 for ( let configToken of Utils . getConfigTokens ( ) ) {
286292 // Mark the credentials as secrets to prevent them from being printed in the logs or exported to other workflows
287293 core . setSecret ( configToken ) ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export interface JfrogCredentials {
1313 oidcProviderName ?: string ;
1414 oidcTokenId ?: string ;
1515 oidcAudience : string ;
16+ githubToken ?: string ;
1617}
1718
1819/**
Original file line number Diff line number Diff line change @@ -317,7 +317,13 @@ export class Utils {
317317 }
318318
319319 public static async configJFrogServers ( jfrogCredentials : JfrogCredentials ) {
320- let cliConfigCmd : string [ ] = [ 'config' ] ;
320+ let cliConfigCmd : string [ ] = [ ] ;
321+ let githubToken : string | undefined = jfrogCredentials . githubToken ;
322+ if ( ! ! githubToken ) {
323+ // Github Token
324+ cliConfigCmd = cliConfigCmd . concat ( '--github-token' , githubToken ) ;
325+ }
326+ cliConfigCmd = cliConfigCmd . concat ( 'config' ) ;
321327 for ( let configToken of Utils . getConfigTokens ( ) ) {
322328 // Mark the credentials as secrets to prevent them from being printed in the logs or exported to other workflows
323329 core . setSecret ( configToken ) ;
Original file line number Diff line number Diff line change @@ -422,4 +422,15 @@ describe('getJfrogCliConfigArgs', () => {
422422 expect ( configString ) . toContain ( '--access-token test-access-token' ) ;
423423 expect ( configString ) . not . toContain ( '--username test-user' ) ;
424424 } ) ;
425+
426+ it ( 'should use github token if provided' , async ( ) => {
427+ const creds : JfrogCredentials = {
428+ jfrogUrl : 'https://example.jfrog.io' ,
429+ accessToken : 'abc' ,
430+ githubToken : 'githubToken' ,
431+ } as JfrogCredentials ;
432+ const args : string [ ] | undefined = await Utils . getJfrogCliConfigArgs ( creds ) ;
433+ expect ( args ) . toContain ( '--github-token' ) ;
434+ expect ( args ) . toContain ( 'githubToken' ) ;
435+ } ) ;
425436} ) ;
You can’t perform that action at this time.
0 commit comments