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

Fix GitHub rate limiting when generating pull request descriptions #1362

Merged
Merged
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
1 change: 1 addition & 0 deletions extension/tasks/dependabotV2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async function run() {
);

const dependabotUpdaterOptions = {
azureDevOpsAccessToken: taskInputs.systemAccessToken,
gitHubAccessToken: taskInputs.githubAccessToken,
collectorImage: undefined, // TODO: Add config for this?
proxyImage: undefined, // TODO: Add config for this?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class DependabotCli {
public async update(
operation: IDependabotUpdateOperation,
options?: {
azureDevOpsAccessToken?: string;
gitHubAccessToken?: string;
collectorImage?: string;
proxyImage?: string;
Expand Down Expand Up @@ -85,6 +86,7 @@ export class DependabotCli {
env: {
DEPENDABOT_JOB_ID: jobId.replace(/-/g, '_'), // replace hyphens with underscores
LOCAL_GITHUB_ACCESS_TOKEN: options?.gitHubAccessToken, // avoid rate-limiting when pulling images from GitHub container registries
LOCAL_AZURE_ACCESS_TOKEN: options?.azureDevOpsAccessToken, // technically not needed since we already supply this in our 'git_source' registry, but included for consistency
},
});
if (dependabotResultCode != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,25 @@ function mapRegistryCredentialsFromDependabotConfigToJobConfig(
): any[] {
let registryCredentials = new Array();
if (taskInputs.systemAccessToken) {
// Required to authenticate with the Azure DevOps git repository when cloning the source code
registryCredentials.push({
type: 'git_source',
host: taskInputs.hostname,
username: taskInputs.systemAccessUser?.trim()?.length > 0 ? taskInputs.systemAccessUser : 'x-access-token',
password: taskInputs.systemAccessToken,
});
}
if (taskInputs.githubAccessToken) {
// Required to avoid rate-limiting errors when generating pull request descriptions (e.g. fetching release notes, commit messages, etc)
registryCredentials.push({
type: 'git_source',
host: 'github.com',
username: 'x-access-token',
password: taskInputs.githubAccessToken,
});
}
if (registries) {
// Required to authenticate with private package feeds when finding the latest version of dependencies
for (const key in registries) {
const registry = registries[key];
registryCredentials.push({
Expand Down