mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 18:25:58 +08:00
feat: add toggle-labels
action (#132)
* feat: add `toggle-labels` action
* docs: update docs
* chore: npm run package
* Revert "docs: update docs"
This reverts commit b08e8f300e
.
* docs: update docs
* Update README.zh-CN.md
Co-authored-by: xrkffgg <xrkffgg@vip.qq.com>
* Update README.md
Co-authored-by: xrkffgg <xrkffgg@vip.qq.com>
* Update README.zh-CN.md
Co-authored-by: xrkffgg <xrkffgg@vip.qq.com>
* Update README.md
* move
* update
* lint code
* build
use npm run all
* update
* build
use npm run all
* chore: order
* update docs
* format code
use npm run format
* build
use npm run all
---------
Co-authored-by: xrkffgg <xrkffgg@vip.qq.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
doCreateComment,
|
||||
doCreateCommentEmoji,
|
||||
doLockIssue,
|
||||
doRemoveLabels,
|
||||
doSetLabels,
|
||||
doUpdateComment,
|
||||
} from './base';
|
||||
@@ -392,3 +393,29 @@ export async function doWelcome(
|
||||
core.info(`[doWelcome] ${auth} is not first time!`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function doToggleLabels(labels: string[] = []) {
|
||||
const issue = await ICE.getIssue();
|
||||
const baseLabels: string[] = issue.labels.map(({ name }: any) => name);
|
||||
|
||||
const addLabels = [];
|
||||
const removeLabels = [];
|
||||
|
||||
for (const label of labels) {
|
||||
if (baseLabels.includes(label)) {
|
||||
removeLabels.push(label);
|
||||
} else {
|
||||
addLabels.push(label);
|
||||
}
|
||||
}
|
||||
|
||||
if (removeLabels.length) {
|
||||
await doRemoveLabels(removeLabels);
|
||||
}
|
||||
|
||||
if (addLabels.length) {
|
||||
await doAddLabels(addLabels);
|
||||
}
|
||||
|
||||
core.info(`[doToggleLabels] Done!`);
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ import {
|
||||
doLockIssues,
|
||||
doMarkAssignees,
|
||||
doMarkDuplicate,
|
||||
doToggleLabels,
|
||||
doWelcome,
|
||||
initAdvancedICE,
|
||||
} from './advanced';
|
||||
@@ -259,6 +260,10 @@ export class IssueHelperEngine implements IIssueHelperEngine {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'toggle-labels': {
|
||||
await doToggleLabels(labels);
|
||||
break;
|
||||
}
|
||||
// -[ Advanced End ]->
|
||||
default: {
|
||||
core.warning(`The ${action} is not allowed.`);
|
||||
|
@@ -56,5 +56,6 @@ export type TAction =
|
||||
| 'lock-issues'
|
||||
| 'mark-assignees'
|
||||
| 'mark-duplicate'
|
||||
| 'welcome';
|
||||
| 'welcome'
|
||||
| 'toggle-labels';
|
||||
//// [ Advanced End ]
|
||||
|
Reference in New Issue
Block a user