Skip to content

Commit ba1a746

Browse files
authored
Remove labels if description changed (#7043)
1 parent 42cb6ca commit ba1a746

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

.github/workflows/pr_labels.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,26 @@ jobs:
3232
['* Documentation', 'documentation'],
3333
['* Not for changelog', 'not-for-changelog']
3434
];
35-
if (!description) return;
35+
// remove all labels owned by current script
36+
for (let pair of mapping) {
37+
try {
38+
const result = await github.rest.issues.removeLabel({
39+
owner,
40+
repo,
41+
issue_number: prNumber,
42+
name: pair[1]
43+
});
44+
console.log('Removed label', pair[1]);
45+
} catch(e) {
46+
console.log(e);
47+
}
48+
}
49+
// add first encountered label
3650
for (let pair of mapping) {
3751
if (!description.includes(pair[0])) continue;
52+
// add label
3853
try {
39-
const result = await github.rest.issues.addLabels({
54+
const result = await github.rest.issues.addLabels({
4055
owner,
4156
repo,
4257
issue_number: prNumber,
@@ -46,5 +61,5 @@ jobs:
4661
} catch(e) {
4762
console.log(e);
4863
}
49-
return;
64+
break;
5065
}

0 commit comments

Comments
 (0)