mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 10:15:59 +08:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
65840f57fe | ||
![]() |
dbeaa215cb | ||
![]() |
6a55b3a9f4 | ||
![]() |
f4eba4debf | ||
![]() |
09bc8811a0 | ||
![]() |
dfac87c369 |
@@ -7,6 +7,12 @@
|
||||
🛠 refactor
|
||||
-->
|
||||
|
||||
## v3.4.0
|
||||
|
||||
`2023.02.06`
|
||||
|
||||
- 🚀 feat: support `toggle-labels`. [#132](https://github.com/actions-cool/issues-helper/pull/132) [@Wxh16144](https://github.com/Wxh16144)
|
||||
|
||||
## v3.3.3
|
||||
|
||||
`2022.11.13`
|
||||
|
36
README.md
36
README.md
@@ -10,7 +10,7 @@
|
||||
|
||||
A GitHub Action that easily helps you automatically manage issues
|
||||
|
||||
[](https://github.com/actions-cool/issues-helper/actions)
|
||||
[](https://github.com/actions-cool/issues-helper/actions)
|
||||
[](https://github.com/marketplace/actions/issues-helper)
|
||||

|
||||
[](https://github.com/umijs/dumi)
|
||||
@@ -255,6 +255,7 @@ When the following list does not have the features you want, you can submit it i
|
||||
- [`lock-issues`](#lock-issues)
|
||||
- [`mark-assignees`](#mark-assignees)
|
||||
- [`mark-duplicate`](#mark-duplicate)
|
||||
- [`toggle-labels`](#toggle-labels)
|
||||
- [`welcome`](#welcome)
|
||||
|
||||
## 🚀 Usage
|
||||
@@ -1109,6 +1110,39 @@ jobs:
|
||||
|
||||
⏫ [Back to list](#List)
|
||||
|
||||
#### `toggle-labels`
|
||||
|
||||
When an issue is reopened, the set labels are removed if they already exist, otherwise they are added.
|
||||
|
||||
```yml
|
||||
name: Toggle Labels
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [reopened]
|
||||
|
||||
jobs:
|
||||
toggle-labels:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Toggle labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'toggle-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
labels: 'unread,outdated'
|
||||
```
|
||||
|
||||
| Param | Desc | Type | Required |
|
||||
| -- | -- | -- | -- |
|
||||
| actions | Action type | string | ✔ |
|
||||
| token | [Token explain](#token) | string | ✖ |
|
||||
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | ✖ |
|
||||
| labels | The toggle labels. Delete if the label already exists, add if it does not exist | string | ✖ |
|
||||
|
||||
⏫ [Back to list](#List)
|
||||
|
||||
#### `welcome`
|
||||
|
||||
When an issue is created, the user who created the issue for the first time is welcome.
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
一个轻松帮你自动管理 issues 的 GitHub Action
|
||||
|
||||
[](https://github.com/actions-cool/issues-helper/actions)
|
||||
[](https://github.com/actions-cool/issues-helper/actions)
|
||||
[](https://github.com/marketplace/actions/issues-helper)
|
||||

|
||||
[](https://github.com/umijs/dumi)
|
||||
@@ -259,6 +259,7 @@
|
||||
- [`lock-issues`](#lock-issues)
|
||||
- [`mark-assignees`](#mark-assignees)
|
||||
- [`mark-duplicate`](#mark-duplicate)
|
||||
- [`toggle-labels`](#toggle-labels)
|
||||
- [`welcome`](#welcome)
|
||||
|
||||
## 🚀 使 用
|
||||
@@ -1108,6 +1109,39 @@ jobs:
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
#### `toggle-labels`
|
||||
|
||||
当一个 issue 被重新打开,判断设置的 labels 如果已经存在则进行删除,否则进行添加。
|
||||
|
||||
```yml
|
||||
name: Toggle Labels
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [reopened]
|
||||
|
||||
jobs:
|
||||
toggle-labels:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Toggle labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'toggle-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
labels: 'unread,outdated'
|
||||
```
|
||||
|
||||
| 参数 | 描述 | 类型 | 必填 |
|
||||
| -- | -- | -- | -- |
|
||||
| actions | 操作类型 | string | ✔ |
|
||||
| token | [token 说明](#token) | string | ✖ |
|
||||
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | ✖ |
|
||||
| labels | 切换 labels。如果 label 已存在则删除,不存在则添加 | string | ✖ |
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
#### `welcome`
|
||||
|
||||
当一个 issue 新建时,对首次新建 issue 的用户进行欢迎。若用户非首次新建,则无操作。
|
||||
|
30
dist/index.js
vendored
30
dist/index.js
vendored
@@ -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.doWelcome = exports.doToggleLabels = 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));
|
||||
@@ -16412,6 +16412,30 @@ function doMarkDuplicate(comment, closeReason, labels, emoji) {
|
||||
});
|
||||
}
|
||||
exports.doMarkDuplicate = doMarkDuplicate;
|
||||
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;
|
||||
function doWelcome(auth, issueNumber, body, labels, assignees, emoji) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info(`[doWelcome] [${auth}]`);
|
||||
@@ -16914,6 +16938,10 @@ class IssueHelperEngine {
|
||||
yield (0, advanced_1.doMarkDuplicate)(ctx.payload.comment, closeReason, labels, emoji);
|
||||
break;
|
||||
}
|
||||
case 'toggle-labels': {
|
||||
yield (0, advanced_1.doToggleLabels)(labels);
|
||||
break;
|
||||
}
|
||||
case 'welcome': {
|
||||
if (ctx.eventName === 'issues' && ctx.payload.action === 'opened') {
|
||||
yield (0, advanced_1.doWelcome)(ctx.actor, issueNumber, body, labels, assignees, emoji);
|
||||
|
@@ -38,6 +38,7 @@ async function run() {
|
||||
if (tags.includes(tagSimple)) {
|
||||
console.log(chalk.yellow(`[Git Action] Delete ${tagSimple} tag`));
|
||||
execSync(`git push origin :refs/tags/${tagSimple}`);
|
||||
console.log(chalk.green(`[Git Action] Delete ${tagSimple} tag success`));
|
||||
}
|
||||
|
||||
console.log(chalk.yellow(`[Git Action] Add new simple ${tagSimple} tag`));
|
||||
|
@@ -16,6 +16,7 @@ import {
|
||||
doCreateComment,
|
||||
doCreateCommentEmoji,
|
||||
doLockIssue,
|
||||
doRemoveLabels,
|
||||
doSetLabels,
|
||||
doUpdateComment,
|
||||
} from './base';
|
||||
@@ -361,6 +362,32 @@ export async function doMarkDuplicate(
|
||||
}
|
||||
}
|
||||
|
||||
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!`);
|
||||
}
|
||||
|
||||
export async function doWelcome(
|
||||
auth: string,
|
||||
issueNumber: number,
|
||||
|
@@ -14,6 +14,7 @@ import {
|
||||
doLockIssues,
|
||||
doMarkAssignees,
|
||||
doMarkDuplicate,
|
||||
doToggleLabels,
|
||||
doWelcome,
|
||||
initAdvancedICE,
|
||||
} from './advanced';
|
||||
@@ -251,6 +252,10 @@ export class IssueHelperEngine implements IIssueHelperEngine {
|
||||
await doMarkDuplicate(ctx.payload.comment as TCommentInfo, closeReason, labels, emoji);
|
||||
break;
|
||||
}
|
||||
case 'toggle-labels': {
|
||||
await doToggleLabels(labels);
|
||||
break;
|
||||
}
|
||||
case 'welcome': {
|
||||
if (ctx.eventName === 'issues' && ctx.payload.action === 'opened') {
|
||||
await doWelcome(ctx.actor, issueNumber, body, labels, assignees, emoji);
|
||||
|
@@ -56,5 +56,6 @@ export type TAction =
|
||||
| 'lock-issues'
|
||||
| 'mark-assignees'
|
||||
| 'mark-duplicate'
|
||||
| 'toggle-labels'
|
||||
| 'welcome';
|
||||
//// [ Advanced End ]
|
||||
|
@@ -351,6 +351,37 @@ Note: Duplicate created with the concise command does not display the content of
|
||||
|
||||

|
||||
|
||||
## `toggle-labels`
|
||||
|
||||
When an issue is reopened, the set labels are removed if they already exist, otherwise they are added.
|
||||
|
||||
```yml
|
||||
name: Toggle Labels
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [reopened]
|
||||
|
||||
jobs:
|
||||
toggle-labels:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Toggle labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'toggle-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
labels: 'unread,outdated'
|
||||
```
|
||||
|
||||
| Param | Desc | Type | Required |
|
||||
| -- | -- | -- | -- |
|
||||
| actions | Action type | string | ✔ |
|
||||
| token | [Token explain](/guide/ref#-token) | string | ✖ |
|
||||
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | ✖ |
|
||||
| labels | The toggle labels. Delete if the label already exists, add if it does not exist | string | ✖ |
|
||||
|
||||
## `welcome`
|
||||
|
||||
When an issue is created, the user who created the issue for the first time is welcome.
|
||||
|
@@ -348,6 +348,37 @@ jobs:
|
||||
|
||||

|
||||
|
||||
## `toggle-labels`
|
||||
|
||||
当一个 issue 被重新打开,判断设置的 labels 如果已经存在则进行删除,否则进行添加。
|
||||
|
||||
```yml
|
||||
name: Toggle Labels
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [reopened]
|
||||
|
||||
jobs:
|
||||
toggle-labels:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Toggle labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'toggle-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
labels: 'unread,outdated'
|
||||
```
|
||||
|
||||
| 参数 | 描述 | 类型 | 必填 |
|
||||
| -- | -- | -- | -- |
|
||||
| actions | 操作类型 | string | ✔ |
|
||||
| token | [token 说明](/zh-CN/guide/ref#-token-说明) | string | ✖ |
|
||||
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | ✖ |
|
||||
| labels | 切换 labels。如果 label 已存在则删除,不存在则添加 | string | ✖ |
|
||||
|
||||
## `welcome`
|
||||
|
||||
当一个 issue 新建时,对首次新建 issue 的用户进行欢迎。若用户非首次新建,则无操作。
|
||||
|
Reference in New Issue
Block a user