Skip to content

Commit dd7932d

Browse files
committed
JPI-396 - add github token param
1 parent 0775fb3 commit dd7932d

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

lib/utils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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);

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface JfrogCredentials {
1313
oidcProviderName?: string;
1414
oidcTokenId?: string;
1515
oidcAudience: string;
16+
githubToken?: string;
1617
}
1718

1819
/**

src/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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);

test/main.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)