mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-20 02:35: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!`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user