Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab4fca9

Browse files
Kartik Rajkarthiknadig
Kartik Raj
andauthored
Ensure any labels or assignees do not carry over when transferring issues to vscode-python (microsoft#19656)
* Ensure any labels or assignees do not carry over when transferring issues to repo * Fix indent * Make list of envs global * Minor edit * Run prettier * Add Eleanor to triage flow Co-authored-by: Karthik Nadig <[email protected]> Co-authored-by: Karthik Nadig <[email protected]>
1 parent fe7bb11 commit ab4fca9

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

.github/workflows/getLabels.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* To run this file:
3+
* * npm install @octokit/rest
4+
* * node .github/workflows/getLabels.js
5+
*/
6+
7+
const { Octokit } = require('@octokit/rest');
8+
const github = new Octokit();
9+
github.rest.issues
10+
.listLabelsForRepo({
11+
owner: 'microsoft',
12+
repo: 'vscode-python',
13+
})
14+
.then((result) => {
15+
const labels = result.data.map((label) => label.name);
16+
console.log(JSON.stringify(labels));
17+
});

.github/workflows/issue-labels.yml

+31-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ on:
44
issues:
55
types: [opened, reopened]
66

7+
env:
8+
# To update the list of labels, see `getLabels.js`.
9+
REPO_LABELS: '["area-data science","area-debugging","area-diagnostics","area-editor-*","area-environments","area-formatting","area-intellisense","area-internal","area-linting","area-terminal","area-testing","author-verification-requested","bug","community ask","debt","dependencies","documentation","experimenting","feature-request","good first issue","help wanted","important","info-needed","invalid-testplan-item","investigating","iteration-candidate","iteration-plan","iteration-plan-draft","javascript","linux"]'
10+
TRIAGERS: '["karrtikr","karthiknadig","paulacamargo25","eleanorjboyd"]'
11+
712
permissions:
813
issues: write
914

1015
jobs:
1116
# From https://github.com/marketplace/actions/github-script#apply-a-label-to-an-issue.
1217
add-classify-label:
13-
name: "Add 'triage-needed'"
18+
name: "Add 'triage-needed' and remove unrecognizable labels & assignees"
1419
runs-on: ubuntu-latest
1520
steps:
1621
- uses: actions/github-script@v6
@@ -37,3 +42,28 @@ jobs:
3742
} else {
3843
console.log('This issue already has a "needs __", "iteration-plan", "release-plan", or the "testplan-item" label, do not add the "triage-needed" label.')
3944
}
45+
const knownLabels = ${{ env.REPO_LABELS }}
46+
const knownTriagers = ${{ env.TRIAGERS }}
47+
for( const label of labels) {
48+
if (!knownLabels.includes(label)) {
49+
await github.rest.issues.deleteLabel({
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
name: label,
53+
})
54+
}
55+
}
56+
const currentAssignees = await github.rest.issues
57+
.get({
58+
owner: context.repo.owner,
59+
repo: context.repo.repo,
60+
issue_number: context.issue.number,
61+
})
62+
.then((result) => result.data.assignees.map((a) => a.login));
63+
const assigneesToRemove = currentAssignees.filter(a => !knownTriagers.includes(a));
64+
github.rest.issues.removeAssignees({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
issue_number: context.issue.number,
68+
assignees: assigneesToRemove,
69+
});

0 commit comments

Comments
 (0)