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:
Wuxh
2023-01-31 12:56:43 +08:00
committed by GitHub
parent f4eba4debf
commit 6a55b3a9f4
8 changed files with 193 additions and 2 deletions

30
dist/index.js vendored
View File

@@ -16060,7 +16060,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.doWelcome = exports.doMarkDuplicate = exports.doMarkAssignees = exports.doLockIssues = exports.doFindIssues = exports.doFindComments = exports.doCloseIssues = exports.doCheckIssue = exports.doCheckInactive = exports.doQueryIssues = exports.initAdvancedICE = void 0;
exports.doToggleLabels = exports.doWelcome = exports.doMarkDuplicate = exports.doMarkAssignees = exports.doLockIssues = exports.doFindIssues = exports.doFindComments = exports.doCloseIssues = exports.doCheckIssue = exports.doCheckInactive = exports.doQueryIssues = exports.initAdvancedICE = void 0;
const actions_util_1 = __nccwpck_require__(6972);
const dayjs_1 = __importDefault(__nccwpck_require__(7401));
const isSameOrBefore_1 = __importDefault(__nccwpck_require__(9517));
@@ -16437,6 +16437,30 @@ function doWelcome(auth, issueNumber, body, labels, assignees, emoji) {
});
}
exports.doWelcome = doWelcome;
function doToggleLabels(labels = []) {
return __awaiter(this, void 0, void 0, function* () {
const issue = yield ICE.getIssue();
const baseLabels = issue.labels.map(({ name }) => name);
const addLabels = [];
const removeLabels = [];
for (const label of labels) {
if (baseLabels.includes(label)) {
removeLabels.push(label);
}
else {
addLabels.push(label);
}
}
if (removeLabels.length) {
yield (0, base_1.doRemoveLabels)(removeLabels);
}
if (addLabels.length) {
yield (0, base_1.doAddLabels)(addLabels);
}
core.info(`[doToggleLabels] Done!`);
});
}
exports.doToggleLabels = doToggleLabels;
/***/ }),
@@ -16923,6 +16947,10 @@ class IssueHelperEngine {
}
break;
}
case 'toggle-labels': {
yield (0, advanced_1.doToggleLabels)(labels);
break;
}
// -[ Advanced End ]->
default: {
core.warning(`The ${action} is not allowed.`);