Skip to content

Commit

Permalink
fix: add remove
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Oct 29, 2021
1 parent 83384c5 commit 6f37d9c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
| format | PR label format. Default `pr(${type})` | string | βœ– |
| extra | Extra replacement | string | βœ– |

- `${type}` will replace the real PR title type.
- `pr-${type}-${type}` is not support.

## ⚑ Feedback

You are very welcome to try it out and put forward your comments. You can use the following methods:
Expand Down
13 changes: 13 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9777,6 +9777,19 @@ function run() {
core.info(`[AC] 🎁 This PR already has ${needLabel}.`);
}
else {
const [b, e] = format.split('${type}');
const removeLabels = prLabels.filter(name => name.startsWith(b) && name.endsWith(e));
if (removeLabels.length) {
for (const label of removeLabels) {
yield octokit.issues.removeLabel({
owner,
repo,
issue_number: number,
name: label,
});
core.info(`[AC] πŸ”” This PR remove ${label} success.`);
}
}
yield octokit.issues.addLabels({
owner,
repo,
Expand Down
15 changes: 15 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ async function run(): Promise<void> {
if (prLabels.indexOf(needLabel) > -1) {
core.info(`[AC] 🎁 This PR already has ${needLabel}.`);
} else {
const [b, e] = format.split('${type}');
const removeLabels = prLabels.filter(name => name.startsWith(b) && name.endsWith(e));

if (removeLabels.length) {
for (const label of removeLabels) {
await octokit.issues.removeLabel({
owner,
repo,
issue_number: number,
name: label,
});
core.info(`[AC] πŸ”” This PR remove ${label} success.`);
}
}

await octokit.issues.addLabels({
owner,
repo,
Expand Down

0 comments on commit 6f37d9c

Please sign in to comment.