Skip to content

Commit

Permalink
Fall back to GitHub CLI for local authentication (#23)
Browse files Browse the repository at this point in the history
If GITHUB_TOKEN is not defined, this will query the `gh` utility for a
PAT, so the index can be generated locally without passing the env
variable to the command.
  • Loading branch information
trond-snekvik authored Nov 3, 2023
1 parent 8927688 commit 6782ba8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/generate-index-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
Application,
} from '../site/src/schema';
import { ParsedOrgFile, readOrgIndexFiles } from './orgFiles';
import { execSync } from 'child_process';

const nordicOrgs: string[] = ['nrfconnect', 'nordic', 'nordicplayground'];
const partnerOrgs: string[] = ['golioth'];
Expand All @@ -29,7 +30,8 @@ function notUndefined<T>(value: T | undefined): value is T {
}

function initialiseGitHubApi() {
const authToken = process.env.GITHUB_TOKEN;
const authToken =
process.env.GITHUB_TOKEN ?? execSync('gh auth token', { encoding: 'utf-8' }).trim();

if (!authToken) {
throw new Error(
Expand Down

0 comments on commit 6782ba8

Please sign in to comment.