mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-18 01:35:58 +08:00
style: update style & changelog
This commit is contained in:
@@ -7,6 +7,12 @@
|
|||||||
🛠 refactor
|
🛠 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
|
## v3.3.3
|
||||||
|
|
||||||
`2022.11.13`
|
`2022.11.13`
|
||||||
|
68
README.md
68
README.md
@@ -255,8 +255,8 @@ When the following list does not have the features you want, you can submit it i
|
|||||||
- [`lock-issues`](#lock-issues)
|
- [`lock-issues`](#lock-issues)
|
||||||
- [`mark-assignees`](#mark-assignees)
|
- [`mark-assignees`](#mark-assignees)
|
||||||
- [`mark-duplicate`](#mark-duplicate)
|
- [`mark-duplicate`](#mark-duplicate)
|
||||||
- [`welcome`](#welcome)
|
|
||||||
- [`toggle-labels`](#toggle-labels)
|
- [`toggle-labels`](#toggle-labels)
|
||||||
|
- [`welcome`](#welcome)
|
||||||
|
|
||||||
## 🚀 Usage
|
## 🚀 Usage
|
||||||
|
|
||||||
@@ -1110,6 +1110,39 @@ jobs:
|
|||||||
|
|
||||||
⏫ [Back to list](#List)
|
⏫ [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`
|
#### `welcome`
|
||||||
|
|
||||||
When an issue is created, the user who created the issue for the first time is welcome.
|
When an issue is created, the user who created the issue for the first time is welcome.
|
||||||
@@ -1151,39 +1184,6 @@ jobs:
|
|||||||
|
|
||||||
⏫ [Back to list](#List)
|
⏫ [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)
|
|
||||||
|
|
||||||
## 🎁 Reference
|
## 🎁 Reference
|
||||||
|
|
||||||
### token
|
### token
|
||||||
|
@@ -259,8 +259,8 @@
|
|||||||
- [`lock-issues`](#lock-issues)
|
- [`lock-issues`](#lock-issues)
|
||||||
- [`mark-assignees`](#mark-assignees)
|
- [`mark-assignees`](#mark-assignees)
|
||||||
- [`mark-duplicate`](#mark-duplicate)
|
- [`mark-duplicate`](#mark-duplicate)
|
||||||
- [`welcome`](#welcome)
|
|
||||||
- [`toggle-labels`](#toggle-labels)
|
- [`toggle-labels`](#toggle-labels)
|
||||||
|
- [`welcome`](#welcome)
|
||||||
|
|
||||||
## 🚀 使 用
|
## 🚀 使 用
|
||||||
|
|
||||||
@@ -1109,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`
|
#### `welcome`
|
||||||
|
|
||||||
当一个 issue 新建时,对首次新建 issue 的用户进行欢迎。若用户非首次新建,则无操作。
|
当一个 issue 新建时,对首次新建 issue 的用户进行欢迎。若用户非首次新建,则无操作。
|
||||||
@@ -1149,39 +1182,6 @@ 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 | ✖ |
|
|
||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
|
||||||
|
|
||||||
## 🎁 参 考
|
## 🎁 参 考
|
||||||
|
|
||||||
### token
|
### token
|
||||||
|
@@ -362,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(
|
export async function doWelcome(
|
||||||
auth: string,
|
auth: string,
|
||||||
issueNumber: number,
|
issueNumber: number,
|
||||||
@@ -393,29 +419,3 @@ export async function doWelcome(
|
|||||||
core.info(`[doWelcome] ${auth} is not first time!`);
|
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!`);
|
|
||||||
}
|
|
||||||
|
@@ -252,6 +252,10 @@ export class IssueHelperEngine implements IIssueHelperEngine {
|
|||||||
await doMarkDuplicate(ctx.payload.comment as TCommentInfo, closeReason, labels, emoji);
|
await doMarkDuplicate(ctx.payload.comment as TCommentInfo, closeReason, labels, emoji);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'toggle-labels': {
|
||||||
|
await doToggleLabels(labels);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'welcome': {
|
case 'welcome': {
|
||||||
if (ctx.eventName === 'issues' && ctx.payload.action === 'opened') {
|
if (ctx.eventName === 'issues' && ctx.payload.action === 'opened') {
|
||||||
await doWelcome(ctx.actor, issueNumber, body, labels, assignees, emoji);
|
await doWelcome(ctx.actor, issueNumber, body, labels, assignees, emoji);
|
||||||
@@ -260,10 +264,6 @@ export class IssueHelperEngine implements IIssueHelperEngine {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'toggle-labels': {
|
|
||||||
await doToggleLabels(labels);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// -[ Advanced End ]->
|
// -[ Advanced End ]->
|
||||||
default: {
|
default: {
|
||||||
core.warning(`The ${action} is not allowed.`);
|
core.warning(`The ${action} is not allowed.`);
|
||||||
|
@@ -56,6 +56,6 @@ export type TAction =
|
|||||||
| 'lock-issues'
|
| 'lock-issues'
|
||||||
| 'mark-assignees'
|
| 'mark-assignees'
|
||||||
| 'mark-duplicate'
|
| 'mark-duplicate'
|
||||||
| 'welcome'
|
| 'toggle-labels'
|
||||||
| 'toggle-labels';
|
| 'welcome';
|
||||||
//// [ Advanced End ]
|
//// [ 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`
|
## `welcome`
|
||||||
|
|
||||||
When an issue is created, the user who created the issue for the first time is welcome.
|
When an issue is created, the user who created the issue for the first time is welcome.
|
||||||
@@ -389,34 +420,3 @@ jobs:
|
|||||||
| issue-emoji | Add [emoji](/guide/ref#-emoji-type) to this issue| string | ✖ |
|
| issue-emoji | Add [emoji](/guide/ref#-emoji-type) to this issue| string | ✖ |
|
||||||
|
|
||||||
- If these 4 options are not filled, no operation
|
- If these 4 options are not filled, no operation
|
||||||
|
|
||||||
## `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 | ✖ |
|
|
||||||
|
@@ -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`
|
## `welcome`
|
||||||
|
|
||||||
当一个 issue 新建时,对首次新建 issue 的用户进行欢迎。若用户非首次新建,则无操作。
|
当一个 issue 新建时,对首次新建 issue 的用户进行欢迎。若用户非首次新建,则无操作。
|
||||||
@@ -384,34 +415,3 @@ jobs:
|
|||||||
| issue-emoji | 为该 issue 增加 [emoji](/zh-CN/guide/ref#-emoji-类型) | string | ✖ |
|
| issue-emoji | 为该 issue 增加 [emoji](/zh-CN/guide/ref#-emoji-类型) | string | ✖ |
|
||||||
|
|
||||||
- 若这 4 个可选项都不填,则无操作
|
- 若这 4 个可选项都不填,则无操作
|
||||||
|
|
||||||
## `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 | ✖ |
|
|
||||||
|
Reference in New Issue
Block a user