Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set GITHUB_API_URL to value of --github-api-url flag #9

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified cli/maven-dependency-submission-linux-x64
Binary file not shown.
70 changes: 2 additions & 68 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3792,7 +3792,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.submitSnapshot = exports.Snapshot = exports.jobFromContext = void 0;
const core = __importStar(__nccwpck_require2_(2186));
const github = __importStar(__nccwpck_require2_(5438));
const rest_1 = __nccwpck_require2_(5375);
const request_error_1 = __nccwpck_require2_(537);
/**
* jobFromContext creates a job from a @actions/github Context
Expand Down Expand Up @@ -3860,9 +3859,7 @@ function submitSnapshot(snapshot, context = github.context) {
core.notice(snapshot.prettyJSON());
const repo = context.repo;
const githubToken = core.getInput('token') || (yield core.getIDToken());
const octokit = new rest_1.Octokit({
auth: githubToken
});
const octokit = github.getOctokit(githubToken);
try {
const response = yield octokit.request('POST /repos/{owner}/{repo}/dependency-graph/snapshots', {
headers: {
Expand Down Expand Up @@ -7460,44 +7457,6 @@ exports.paginatingEndpoints = paginatingEndpoints;
//# sourceMappingURL=index.js.map


/***/ }),

/***/ 8883:
/***/ ((__unused_webpack_module, exports) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({ value: true }));

const VERSION = "1.0.4";

/**
* @param octokit Octokit instance
* @param options Options passed to Octokit constructor
*/

function requestLog(octokit) {
octokit.hook.wrap("request", (request, options) => {
octokit.log.debug("request", options);
const start = Date.now();
const requestOptions = octokit.request.endpoint.parse(options);
const path = requestOptions.url.replace(options.baseUrl, "");
return request(options).then(response => {
octokit.log.info(`${requestOptions.method} ${path} - ${response.status} in ${Date.now() - start}ms`);
return response;
}).catch(error => {
octokit.log.info(`${requestOptions.method} ${path} - ${error.status} in ${Date.now() - start}ms`);
throw error;
});
});
}
requestLog.VERSION = VERSION;

exports.requestLog = requestLog;
//# sourceMappingURL=index.js.map


/***/ }),

/***/ 3044:
Expand Down Expand Up @@ -8798,31 +8757,6 @@ exports.request = request;
//# sourceMappingURL=index.js.map


/***/ }),

/***/ 5375:
/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({ value: true }));

var core = __nccwpck_require2_(6762);
var pluginRequestLog = __nccwpck_require2_(8883);
var pluginPaginateRest = __nccwpck_require2_(4193);
var pluginRestEndpointMethods = __nccwpck_require2_(3044);

const VERSION = "18.12.0";

const Octokit = core.Octokit.plugin(pluginRequestLog.requestLog, pluginRestEndpointMethods.legacyRestEndpointMethods, pluginPaginateRest.paginateRest).defaults({
userAgent: `octokit-rest.js/${VERSION}`
});

exports.Octokit = Octokit;
//# sourceMappingURL=index.js.map


/***/ }),

/***/ 3682:
Expand Down Expand Up @@ -15713,7 +15647,7 @@ module.exports = require("zlib");
/***/ ((module) => {

"use strict";
module.exports = {"i8":"1.1.0"};
module.exports = {"i8":"2.0.0"};

/***/ })

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"homepage": "https://github.com/advanced-security/maven-dependency-tree-action#readme",
"dependencies": {
"@actions/core": "^1.10.0",
"@github/dependency-submission-toolkit": "^1.2.3",
"@github/dependency-submission-toolkit": "^1.2.6",
"commander": "^9.4.0",
"packageurl-js": "^0.0.7"
},
Expand Down
21 changes: 14 additions & 7 deletions src/executable/cli.ts
Original file line number Diff line number Diff line change
@@ -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();