Skip to content

Commit

Permalink
Add support for enterprise server (I hope!)
Browse files Browse the repository at this point in the history
  • Loading branch information
underrobyn committed Jan 2, 2024
1 parent 2d247b6 commit 19b2a8f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/task/common/failTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export default async function failTask() {
});

// If in audit mode then we will succeed with issues, else we fail the task to halt the pipeline.

const taskResult = auditMode ? tl.TaskResult.SucceededWithIssues : tl.TaskResult.Failed;
tl.setResult(taskResult, 'Dependabot alerts caused pipeline failure.');

return;
}

Expand Down
13 changes: 11 additions & 2 deletions src/task/common/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ async function getGitHubInstance() {
const authentication = await auth();
const fetchImplementation = typeof(fetch) === "undefined" ? nodeFetch : fetch;

return new OctokitPaginate({
let config = {
auth: authentication.token,
request: {
fetch: fetchImplementation,
}
});
};

// If enterprise server URL specified, use as baseUrl
const enterpriseServerUrl = tl.getInput('enterpriseServerUrl');
if (enterpriseServerUrl) {
config['baseUrl'] = enterpriseServerUrl;
tl.debug(`Setting Octokit baseURL to ${enterpriseServerUrl}`);
}

return new OctokitPaginate(config);
}

export async function getRateLimitInfo() {
Expand Down
9 changes: 9 additions & 0 deletions src/task/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@
"defaultValue": "",
"required": false,
"helpMarkDown": "Personal Access Token used for accessing GitHub repositories (requires security_events scope)"
},
{
"name": "enterpriseServerUrl",
"type": "string",
"groupName": "github_connection",
"label": "Enterprise Server URL (if applicable)",
"defaultValue": "",
"required": false,
"helpMarkDown": "If you use GitHub Enterprise Server, specify API URL here, e.g. https://github.acme-inc.com/api/v3"
}
],
"dataSourceBindings": [],
Expand Down

0 comments on commit 19b2a8f

Please sign in to comment.