Skip to content

Commit 2fb8c5d

Browse files
committed
chore: use github token passed from an arg
1 parent 5713cd5 commit 2fb8c5d

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

services/apps/script_executor_worker/src/bin/onboard-projects.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* - Console output of failed projects for easy troubleshooting
1515
*
1616
* Usage:
17-
* tsx src/bin/onboard-projects.ts <bearer-token> <csv-file-path> [--dry-run]
17+
* tsx src/bin/onboard-projects.ts <bearer-token> <github-token> <csv-file-path> [--dry-run]
1818
*
1919
* CSV Format:
2020
* project name,project slug,repo url
@@ -52,13 +52,15 @@ const LF_OSS_INDEX_PROJECT_GROUP_SLUG = 'lf-oss-index'
5252
* GitHub integration.
5353
*
5454
* @param csvFilePath - Path to the CSV file containing project data
55-
* @param bearerToken - Authentication token for API calls
55+
* @param bearerToken - Authentication token for CDP API calls
56+
* @param githubToken - GitHub token for API calls
5657
* @param isDryRun - If true, only processes the first project for testing
5758
* @returns Promise resolving to results summary including success/failure counts and failed projects
5859
*/
5960
async function onboardProjectsFromCsv(
6061
csvFilePath: string,
6162
bearerToken: string,
63+
githubToken: string,
6264
isDryRun = false,
6365
): Promise<{
6466
successCount: number
@@ -145,7 +147,7 @@ async function onboardProjectsFromCsv(
145147
if (segmentId) {
146148
try {
147149
// Create GitHub integration
148-
await createGithubIntegration(project, segmentId, bearerToken)
150+
await createGithubIntegration(project, segmentId, bearerToken, githubToken)
149151
log.info(`Created GitHub integration for project ${project.name}`)
150152

151153
successCount++
@@ -264,12 +266,13 @@ async function createGithubIntegration(
264266
project: ProjectRow,
265267
segmentId: string,
266268
bearerToken: string,
269+
githubToken: string,
267270
): Promise<void> {
268271
// Parse GitHub repo URL to extract owner and repo name
269272
const { owner, repo } = parseGithubUrl(project.repoUrl)
270273

271274
// Fetch organization logo
272-
const orgLogo = await fetchGithubOrgLogo(owner, bearerToken)
275+
const orgLogo = await fetchGithubOrgLogo(owner, githubToken)
273276

274277
// Create integration
275278
const integrationUrl = `${process.env['CROWD_API_SERVICE_URL']}/github-nango-connect`
@@ -377,12 +380,13 @@ function parseGithubUrl(repoUrl: string): { owner: string; repo: string } {
377380
async function main() {
378381
const args = process.argv.slice(2)
379382

380-
if (args.length < 2 || args.length > 3) {
383+
if (args.length < 3 || args.length > 4) {
381384
log.error(`
382-
Usage: tsx src/bin/onboard-projects.ts <bearer-token> <csv-file-path> [--dry-run]
385+
Usage: tsx src/bin/onboard-projects.ts <bearer-token> <github-token> <csv-file-path> [--dry-run]
383386
384387
Arguments:
385-
bearer-token: Bearer token for API authentication
388+
bearer-token: Bearer token for CDP API authentication
389+
github-token: GitHub token for fetching organization logos
386390
csv-file-path: Path to CSV file containing projects to onboard
387391
--dry-run: (optional) Test mode - only process the first project from CSV
388392
@@ -400,7 +404,7 @@ async function main() {
400404
process.exit(1)
401405
}
402406

403-
const [bearerToken, csvFilePath, dryRunFlag] = args
407+
const [bearerToken, githubToken, csvFilePath, dryRunFlag] = args
404408
const isDryRun = dryRunFlag === '--dry-run'
405409

406410
// Validate file exists
@@ -420,7 +424,7 @@ async function main() {
420424

421425
try {
422426
// Run the onboarding function directly
423-
const result = await onboardProjectsFromCsv(resolvedPath, bearerToken, isDryRun)
427+
const result = await onboardProjectsFromCsv(resolvedPath, bearerToken, githubToken, isDryRun)
424428

425429
log.info(`
426430
Onboarding completed successfully: ${result.successCount} successful, ${result.failureCount} failed

0 commit comments

Comments
 (0)