Skip to content

Commit

Permalink
Set GITHUB_API_URL to value of --github-api-url flag
Browse files Browse the repository at this point in the history
  • Loading branch information
aibaars committed Oct 25, 2022
1 parent 571e99a commit 89b023f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/executable/cli.ts
@@ -1,5 +1,3 @@
import { Snapshot, submitSnapshot } from '@github/dependency-submission-toolkit';
import { generateSnapshot } from '../snapshot-generator';
import pkg from '../../package.json';

const { program } = require('commander');
Expand All @@ -18,13 +16,22 @@ program.option('-i --run-id <jobName>', 'Optional Run ID number for the activity

program.parse(process.argv);

const opts = program.opts();

// Inject some required environment variables like the Actions INPUTs and special environment variables
process.env['INPUT_TOKEN'] = opts.token;
process.env['GITHUB_REPOSITORY'] = opts.repository;
if (opts.githubApiUrl) {
process.env['GITHUB_API_URL'] = opts.githubApiUrl;
}

// Import dependency-submission-toolkit after setting GITHUB_API_URL
import { Snapshot, submitSnapshot } from '@github/dependency-submission-toolkit';
import { generateSnapshot } from '../snapshot-generator';

async function execute() {
const opts = program.opts();

// Inject some required environment variables like the Actions INPUTs and special environment variables
process.env['INPUT_TOKEN'] = opts.token;
process.env['GITHUB_REPOSITORY'] = opts.repository;

let snapshot: Snapshot | undefined;
try {
// Build a fake GitHub Actions context so that values for the submission APIs can be retrieved
Expand Down Expand Up @@ -63,4 +70,4 @@ async function execute() {
}
}

execute();
execute();

0 comments on commit 89b023f

Please sign in to comment.