Skip to content

Commit 26d0932

Browse files
authored
Merge pull request #12610 from microsoft/main
Merge for 1.22.0 (pre-release)
2 parents 825033f + d7bfae6 commit 26d0932

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3755
-2613
lines changed

.github/actions/AddComment/AddComment.js

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See LICENSE in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { GitHub } from '../api/api';
7+
import { ActionBase } from '../common/ActionBase';
8+
import { daysAgoToHumanReadbleDate, daysAgoToTimestamp, safeLog } from '../common/utils';
9+
10+
export class AddComment extends ActionBase {
11+
constructor(
12+
private github: GitHub,
13+
private createdAfter: string,
14+
private afterDays: number,
15+
labels: string,
16+
private addComment: string,
17+
private addLabels?: string,
18+
private removeLabels?: string,
19+
private setMilestoneId?: string,
20+
milestoneName?: string,
21+
milestoneId?: string,
22+
ignoreLabels?: string,
23+
ignoreMilestoneNames?: string,
24+
ignoreMilestoneIds?: string,
25+
minimumVotes?: number,
26+
maximumVotes?: number,
27+
involves?: string
28+
) {
29+
super(labels, milestoneName, milestoneId, ignoreLabels, ignoreMilestoneNames, ignoreMilestoneIds, minimumVotes, maximumVotes, involves);
30+
}
31+
32+
async run() {
33+
const updatedTimestamp = this.afterDays ? daysAgoToHumanReadbleDate(this.afterDays) : undefined;
34+
const query = this.buildQuery(
35+
(updatedTimestamp ? `updated:<${updatedTimestamp} ` : "") +
36+
(this.createdAfter ? `created:>${this.createdAfter} ` : "") +
37+
"is:open is:unlocked");
38+
39+
const addLabelsSet = this.addLabels ? this.addLabels.split(',') : [];
40+
const removeLabelsSet = this.removeLabels ? this.removeLabels.split(',') : [];
41+
42+
for await (const page of this.github.query({ q: query })) {
43+
for (const issue of page) {
44+
const hydrated = await issue.getIssue();
45+
if (hydrated.open && this.validateIssue(hydrated)
46+
// TODO: Verify updated timestamp
47+
) {
48+
if (this.addComment) {
49+
safeLog(`Posting comment on issue ${hydrated.number}`);
50+
await issue.postComment(this.addComment);
51+
}
52+
if (removeLabelsSet.length > 0) {
53+
for (const removeLabel of removeLabelsSet) {
54+
if (removeLabel && removeLabel.length > 0) {
55+
safeLog(`Removing label on issue ${hydrated.number}: ${removeLabel}`);
56+
await issue.removeLabel(removeLabel);
57+
}
58+
}
59+
}
60+
if (addLabelsSet.length > 0) {
61+
for (const addLabel of addLabelsSet) {
62+
if (addLabel && addLabel.length > 0) {
63+
safeLog(`Adding label on issue ${hydrated.number}: ${addLabel}`);
64+
await issue.addLabel(addLabel);
65+
}
66+
}
67+
}
68+
if (this.setMilestoneId != undefined) {
69+
safeLog(`Setting milestone of issue ${hydrated.number} to id ${+this.setMilestoneId}`);
70+
await issue.setMilestone(+this.setMilestoneId);
71+
}
72+
safeLog(`Processing issue ${hydrated.number}.`);
73+
} else {
74+
if (!hydrated.open) {
75+
safeLog(`Issue ${hydrated.number} is not open. Ignoring`);
76+
}
77+
}
78+
}
79+
}
80+
}
81+
}

.github/actions/AddComment/action.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Add Comment and Label
2+
description: Add comment (etc) to issues that are marked with a specified label (etc)
3+
inputs:
4+
token:
5+
description: GitHub token with issue, comment, and label read/write permissions
6+
default: ${{ github.token }}
7+
createdAfter:
8+
description: Creation date after which to be considered.
9+
required: false
10+
afterDays:
11+
description: Days to wait before performing this action (may be 0).
12+
required: false
13+
addComment:
14+
description: Comment to add
15+
labels:
16+
description: items with these labels will be considered. May be "*".
17+
required: true
18+
milestoneName:
19+
description: items with these milestones will be considered (name only, must match ID)
20+
milestoneId:
21+
description: items with these milestones will be considered (id only, must match name)
22+
ignoreLabels:
23+
description: items with these labels will not be considered
24+
ignoreMilestoneNames:
25+
description: items with these milestones will not be considered (names only, must match IDs). May be "*".
26+
ignoreMilestoneIds:
27+
description: items with these milestones will not be considered (IDs only, must match names)
28+
addLabels:
29+
description: Labels to add to issue.
30+
removeLabels:
31+
description: Labels to remove from issue.
32+
minimumVotes:
33+
descriptions: Only issues with at least this many votes will be considered.
34+
maximumVotes:
35+
descriptions: Only issues fewer or equal to this many votes will be considered.
36+
involves:
37+
descriptions: Qualifier to find issues that in some way involve a certain user either as an author, assignee, or mentions.
38+
readonly:
39+
description: If true, changes are not applied.
40+
runs:
41+
using: 'node12'
42+
main: 'index.js'

.github/actions/AddComment/index.js

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/AddComment/index.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See LICENSE in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { OctoKit } from '../api/octokit'
7+
import { getInput, getRequiredInput } from '../common/utils'
8+
import { AddComment } from './AddComment'
9+
import { Action } from '../common/Action'
10+
11+
class AddCommentAction extends Action {
12+
id = 'AddComment';
13+
14+
async onTriggered(github: OctoKit) {
15+
await new AddComment(
16+
github,
17+
getInput('createdAfter') || undefined,
18+
+(getInput('afterDays') || 0),
19+
getRequiredInput('labels'),
20+
getInput('addComment') || '',
21+
getInput('addLabels') || undefined,
22+
getInput('removeLabels') || undefined,
23+
getInput('setMilestoneId') || undefined,
24+
getInput('milestoneName') || undefined,
25+
getInput('milestoneId') || undefined,
26+
getInput('ignoreLabels') || undefined,
27+
getInput('ignoreMilestoneNames') || undefined,
28+
getInput('ignoreMilestoneIds') || undefined,
29+
+(getInput('minimumVotes') || 0),
30+
+(getInput('maximumVotes') || 9999999),
31+
getInput('involves') || undefined
32+
).run();
33+
}
34+
}
35+
36+
new AddCommentAction().run(); // eslint-disable-line

.github/actions/Locker/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ inputs:
1515
milestoneId:
1616
description: items with these milestones will be considered (id only, must match name)
1717
labels:
18-
description: items with these labels will not be considered. May be "*".
18+
description: items with these labels will be considered. May be "*".
1919
ignoreMilestoneNames:
2020
description: items with these milestones will not be considered (names only, must match IDs). May be "*".
2121
ignoreMilestoneIds:

.github/actions/Reopener/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ inputs:
1919
milestoneId:
2020
description: items with these milestones will be considered (id only, must match name)
2121
labels:
22-
description: items with these labels will not be considered. May be "*".
22+
description: items with these labels will be considered. May be "*".
2323
ignoreMilestoneNames:
2424
description: items with these milestones will not be considered (names only, must match IDs). May be "*".
2525
ignoreMilestoneIds:

0 commit comments

Comments
 (0)