feat(dev-infra): automatically add labels to release PRs (#40016)

Automatically add provided labels to PRs created for release.

PR Close #40016
This commit is contained in:
Joey Perrott 2021-01-19 12:37:12 -08:00 committed by Jessica Janiuk
parent 17d2c8d7fa
commit 158269cb94
4 changed files with 15 additions and 2 deletions

View File

@ -32,7 +32,5 @@ export const release: ReleaseConfig = {
generateReleaseNotesForHead: async () => {
exec('yarn -s gulp changelog', {cwd: join(__dirname, '../')});
},
// The `comp: *` labels will be automatically added by PullApprove and the targeting label will
// be added by the release tooling, only `action: merge` must be manually included to the list.
releasePrLabels: ['comp: build & ci', 'action: merge', 'PullApprove: disable'],
};

View File

@ -5676,6 +5676,10 @@ class ReleaseAction {
const { fork, branchName } = yield this._pushHeadToFork(proposedForkBranchName, true);
const { data } = yield this.git.github.pulls.create(Object.assign(Object.assign({}, this.git.remoteParams), { head: `${fork.owner}:${branchName}`, base: targetBranch, body,
title }));
// Add labels to the newly created PR if provided in the configuration.
if (this.config.releasePrLabels !== undefined) {
yield this.git.github.issues.addLabels(Object.assign(Object.assign({}, this.git.remoteParams), { issue_number: data.number, labels: this.config.releasePrLabels }));
}
info(green(` ✓ Created pull request #${data.number} in ${repoSlug}.`));
return {
id: data.number,

View File

@ -34,6 +34,8 @@ export interface ReleaseConfig {
*/
// TODO: Remove this in favor of a canonical changelog format across the Angular organization.
extractReleaseNotesPattern?: (version: semver.SemVer) => RegExp;
/** The list of github labels to add to the release PRs. */
releasePrLabels?: string[];
}
/** Configuration for releases in the dev-infra configuration. */

View File

@ -282,6 +282,15 @@ export abstract class ReleaseAction {
title,
});
// Add labels to the newly created PR if provided in the configuration.
if (this.config.releasePrLabels !== undefined) {
await this.git.github.issues.addLabels({
...this.git.remoteParams,
issue_number: data.number,
labels: this.config.releasePrLabels,
});
}
info(green(` ✓ Created pull request #${data.number} in ${repoSlug}.`));
return {
id: data.number,