mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-10-14 07:43:46 +08:00
docs: update
This commit is contained in:
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: 🐛 报告 bug
|
||||||
|
about: Report Bug.
|
||||||
|
title: '[BUG] Report bug'
|
||||||
|
labels: 'bug'
|
||||||
|
assignees:
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🐛 Bug 描述 Bug description
|
||||||
|
|
||||||
|
<!-- 请在上方详细地描述 bug,让大家都能理解。 -->
|
||||||
|
<!-- Please describe the bug in detail above so that everyone can understand. -->
|
||||||
|
|
||||||
|
### 🏞 期望结果 Desired result
|
||||||
|
|
||||||
|
<!-- 请在上方描述你原本期望看到的结果。 -->
|
||||||
|
<!-- Please describe above what you expected to see. -->
|
||||||
|
|
||||||
|
### 🚑 其他信息 Other information
|
||||||
|
|
||||||
|
<!-- 请在上方输入,如截图等其他信息。-->
|
||||||
|
<!-- Please enter other information such as screenshots above. -->
|
||||||
|
|
||||||
|
<!-- From: https://github.com/one-template/issue-template -->
|
24
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: 🌟 需求、功能、建议
|
||||||
|
about: Needs, functions, suggestions.
|
||||||
|
title: '[Feature] New function'
|
||||||
|
labels: 'feature'
|
||||||
|
assignees:
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🥰 需求描述 Description of Requirement
|
||||||
|
|
||||||
|
<!-- 请在上方详细地描述需求,让大家都能理解。 -->
|
||||||
|
<!-- Please describe you need in detail above so that everyone can understand. -->
|
||||||
|
|
||||||
|
### 🧐 解决方案 Solution
|
||||||
|
|
||||||
|
<!-- 如果你有解决方案,请在上方清晰地阐述。 -->
|
||||||
|
<!-- If you have a solution, please state it clearly above. -->
|
||||||
|
|
||||||
|
### 🚑 其他信息 Other information
|
||||||
|
|
||||||
|
<!-- 请在上方输入,如截图等其他信息。-->
|
||||||
|
<!-- Please enter other information such as screenshots above. -->
|
||||||
|
|
||||||
|
<!-- From: https://github.com/one-template/issue-template -->
|
24
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: '❓ 疑问或需要帮助'
|
||||||
|
about: Question or need help
|
||||||
|
title: '[Question] Help'
|
||||||
|
labels: 'question'
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🧐 问题描述 Problem Description
|
||||||
|
|
||||||
|
<!-- 详细地描述问题,让大家都能理解。 -->
|
||||||
|
<!-- Describe the problem in detail so that everyone can understand. -->
|
||||||
|
|
||||||
|
### 💻 示例代码 Sample code
|
||||||
|
|
||||||
|
<!-- 如果你有解决方案,在这里清晰地阐述。 -->
|
||||||
|
<!-- If you have a solution, state it clearly here. -->
|
||||||
|
|
||||||
|
### 🚑 其他信息 Other information
|
||||||
|
|
||||||
|
<!-- 如截图等其他信息可以贴在这里。 -->
|
||||||
|
<!-- Other information such as screenshots can be posted here. -->
|
||||||
|
|
||||||
|
<!-- From: https://github.com/one-template/issue-template -->
|
19
.github/ISSUE_TEMPLATE/resource.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE/resource.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: '💎 资源参考'
|
||||||
|
about: Reference resources
|
||||||
|
title: '[Resource] some'
|
||||||
|
labels: 'resource'
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
### 😎 资源类别 Resource category
|
||||||
|
|
||||||
|
<!-- 描述你所提供资源的类别。 -->
|
||||||
|
<!-- Describe the type of resource you provide. -->
|
||||||
|
|
||||||
|
### 🎨 资源内容 Resource content
|
||||||
|
|
||||||
|
<!-- 列出你所提供资源的详细内容。 -->
|
||||||
|
<!-- List the details of the resources you provide. -->
|
||||||
|
|
||||||
|
<!-- From: https://github.com/one-template/issue-template -->
|
55
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
55
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<!--
|
||||||
|
首先,感谢你的贡献!😄
|
||||||
|
First of all, thank you for your contribution! 😄
|
||||||
|
-->
|
||||||
|
|
||||||
|
### 🤔 这个变动的性质是?/ What is the nature of this change?
|
||||||
|
|
||||||
|
- [ ] 新特性提交 / New feature
|
||||||
|
- [ ] bug 修复 / Fix bug
|
||||||
|
- [ ] 样式优化 / Style optimization
|
||||||
|
- [ ] 包体积优化 / Package size optimization
|
||||||
|
- [ ] 性能优化 / Performance optimization
|
||||||
|
- [ ] 代码风格优化 / Code style optimization
|
||||||
|
- [ ] 构建优化 / Build optimization
|
||||||
|
- [ ] 网站、文档、Demo 改进 / Website, documentation, demo improvements
|
||||||
|
- [ ] 测试相关 / Test related
|
||||||
|
- [ ] 其他 / Other
|
||||||
|
|
||||||
|
### 🔗 相关 Issue / Related Issue
|
||||||
|
|
||||||
|
<!--
|
||||||
|
描述相关需求的来源,如相关的 issue 讨论链接。
|
||||||
|
Describe the source of related requirements, such as the related issue discussion link.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### 💡 需求背景和解决方案 / Background or solution
|
||||||
|
|
||||||
|
<!--
|
||||||
|
解决的具体问题。
|
||||||
|
The specific problem solved.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### 📝 更新日志 / Changelog
|
||||||
|
|
||||||
|
<!--
|
||||||
|
从用户角度描述具体变化,以及可能的 breaking change 和其他风险。
|
||||||
|
Describe changes from the user side, and list all potential break changes or other risks.
|
||||||
|
--->
|
||||||
|
|
||||||
|
| Language | Changelog |
|
||||||
|
| ---------- | --------- |
|
||||||
|
| 🇺🇸 English | |
|
||||||
|
| 🇨🇳 Chinese | |
|
||||||
|
|
||||||
|
|
||||||
|
### ☑️ 请求合并前的自查清单 / Self Check before Merge
|
||||||
|
|
||||||
|
⚠️ 请自检并全部**勾选全部选项**。/ Please check all items below before review. ⚠️
|
||||||
|
|
||||||
|
- [ ] 文档已补充或无须补充 / Doc is updated/provided or not needed
|
||||||
|
- [ ] 代码演示已提供或无须提供 / Demo is updated/provided or not needed
|
||||||
|
- [ ] TypeScript 定义已补充或无须补充 / TypeScript definition is updated/provided or not needed
|
||||||
|
- [ ] Changelog 已提供或无须提供 / Changelog is provided or not needed
|
||||||
|
|
||||||
|
<!-- From: https://github.com/one-template/pr-template -->
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,7 +14,6 @@ yarn-error.log*
|
|||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.env
|
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
node_modules
|
node_modules
|
||||||
|
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020 GitHub Actions
|
Copyright (c) 2020 xrkffgg
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
439
README.md
439
README.md
@@ -1,13 +1,438 @@
|
|||||||
# 🤖 Issue Helper
|
# 🤖 Issue Helper
|
||||||
|
|
||||||
A GitHub action to help you deal with the issue.
|
English | [简体中文](./README.zh-CN.md)
|
||||||
|
|
||||||
最开始:
|
一个帮你处理 issue 的 GitHub Action
|
||||||
- 确保 token 拥有当前项目的 push 权限。
|
|
||||||
|
|
||||||
## Usage
|
## 😎 为什么用 GitHub Action?
|
||||||
### `add-assignees`
|
|
||||||
|
|
||||||
### `add-labels`
|
1. 完全免费。
|
||||||
|
2. 全自动操作。
|
||||||
|
3. 托管于 GitHub 服务器,只要 GitHub 不宕机,它就会一直跑下去。
|
||||||
|
|
||||||
### `create-comment`
|
> Private 项目每月有 2000 次的限制,[具体查看](https://github.com/settings/billing)。Public 项目无限制。
|
||||||
|
|
||||||
|
## 列 表
|
||||||
|
|
||||||
|
- ⭐ 基 础
|
||||||
|
- [`add-assignees`](#add-assignees)
|
||||||
|
- [`add-labels`](#add-labels)
|
||||||
|
- [`create-comment`](#create-comment)
|
||||||
|
- [`create-issue`](#create-issue)
|
||||||
|
- [`delete-comment`](#delete-comment)
|
||||||
|
- [`lock-issue`](#lock-issue)
|
||||||
|
- [`remove-assignees`](#remove-assignees)
|
||||||
|
- [`set-labels`](#set-labels)
|
||||||
|
- [`unlock-issue`](#unlock-issue)
|
||||||
|
- [`update-comment`](#update-comment)
|
||||||
|
- [`update-issue`](#update-issue)
|
||||||
|
- ⭐ 进 阶
|
||||||
|
- ⭐ 高 级
|
||||||
|
|
||||||
|
## 🚀 使 用
|
||||||
|
|
||||||
|
### ⭐ 基 础
|
||||||
|
|
||||||
|
为了更好的展示功能,下面以实际场景举例,请灵活参考。
|
||||||
|
|
||||||
|
#### `add-assignees`
|
||||||
|
|
||||||
|
当一个 issue 新增时,将这个 issue 指定某人或多人。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Add Assigness
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
add-assigness:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Add assigness
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'add-assignees' or ['add-assignees']
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
assignees: 'xxx' or ['xxx'] or ['xx1', 'xx2']
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
| assignees | 指定人。当不填或者为空字符、空数组时,不指定 | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
|
- 其中的 `name` 可根据自行根据实际情况修改
|
||||||
|
- [on 参考](#触发机制)
|
||||||
|
- `${{ github.event.issue.number }}` 表示当前 issue。[更多参考](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events)。
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `add-labels`
|
||||||
|
|
||||||
|
当一个新增的 issue 内容不包含指定格式时,为这个 issue 添加 labels。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Add Labels
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
add-labels:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.issue.body.indexOf('Create by specifying way') == -1
|
||||||
|
steps:
|
||||||
|
- name: Add labels
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'add-labels'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
labels: 'bug' or ['bug'] or ['bug1', 'bug2']
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
| labels | 新增的 labels。当不填或者为空字符、空数组时,不新增 | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `create-comment`
|
||||||
|
|
||||||
|
当新增一个指定 label 时,对该 issue 进行评论。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Create Comment
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [labeled]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-comment:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.label.name == 'xxx'
|
||||||
|
steps:
|
||||||
|
- name: Create comment
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'create-comment'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
body: |
|
||||||
|
Hello ${{ github.event.issue.user.login }}. Add some comments.
|
||||||
|
|
||||||
|
你好 ${{ github.event.issue.user.login }}。巴拉巴拉。
|
||||||
|
contents: '+1' or ['+1', 'heart']
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
| body | 新增评论的内容 | string | ✖ | v1 |
|
||||||
|
| contents | 为新增评论的增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
|
- `body` 默认为:`Currently at ${owner}/${repo}. And this is default comment.`
|
||||||
|
- 其中 `${owner}/${repo}` 表示当前仓库
|
||||||
|
- 返回 `comment-id`,可用于之后操作。用法参考
|
||||||
|
- `${{ github.event.issue.user.login }}` 表示该 issue 的创建者。
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `create-issue`
|
||||||
|
|
||||||
|
感觉新增 issue 使用场景不多。这里举例,每月 1 号 UTC 00:00 新增一个 issue。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Create Issue
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 1 * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-issue:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create issue
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'create-issue'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
title: 'xxxx'
|
||||||
|
body: 'xxxx'
|
||||||
|
labels: 'xx'
|
||||||
|
assignees: 'xxx'
|
||||||
|
contents: '+1'
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| title | 新增 issue 的标题 | string | ✖ | v1 |
|
||||||
|
| body | 新增 issue 的内容 | string | ✖ | v1 |
|
||||||
|
| labels | 为新增 issue 添加 labels | string \| string\[] | ✖ | v1 |
|
||||||
|
| assignees | 为新增 issue 添加 assignees | string \| string\[] | ✖ | v1 |
|
||||||
|
| contents | 为新增 issue 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
|
- `title` 默认为:`Default Title`
|
||||||
|
- `body` 默认同上
|
||||||
|
- 返回 `issue_number`,用法同上
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `delete-comment`
|
||||||
|
|
||||||
|
根据 [`comment_id`](#comment_id-获取) 删除指定评论。单个应用场景不多,可参考高级用法。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Delete comment
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'delete-comment'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
comment-id: xxx
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| comment-id | 指定的 comment | number | ✔ | v1 |
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `lock-issue`
|
||||||
|
|
||||||
|
当新增 `invalid` label 时,对该 issue 进行锁定。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Lock Issue
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [labeled]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lock-issue:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.label.name == 'invalid'
|
||||||
|
steps:
|
||||||
|
- name: Lock issue
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'lock-issue'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `remove-assignees`
|
||||||
|
|
||||||
|
移除 issue 指定人员。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Remove assignees
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'remove-assignees'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
assignees: 'xx'
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
| assignees | 移除的指定人。当不填或者为空字符、空数组时,不进行移除 | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `set-labels`
|
||||||
|
|
||||||
|
设置 issue 的 labels。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Set labels
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'set-labels'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
labels: 'xx'
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
| labels | labels 设置。当不填或者为空字符、空数组时,会移除所有 | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `unlock-issue`
|
||||||
|
|
||||||
|
解锁指定 issue。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Unlock issue
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'unlock-issue'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `update-comment`
|
||||||
|
|
||||||
|
根据 [`comment_id`](#comment_id-获取) 更新指定评论。单个应用场景不多,可参考高级用法。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Update comment
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'update-comment'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
comment-id: xxx
|
||||||
|
body: 'xxxx'
|
||||||
|
update-mode: 'replace'
|
||||||
|
contents: '+1'
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| comment-id | 指定的 comment | number | ✔ | v1 |
|
||||||
|
| body | 更新 comment 的内容 | string | ✖ | v1 |
|
||||||
|
| update-mode | 更新模式。`replace` 替换,`append` 附加 | string | ✖ | v1 |
|
||||||
|
| contents | 为 comment 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
|
- `body` 默认同上
|
||||||
|
- `update-mode` 为 `append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效。
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `update-issue`
|
||||||
|
|
||||||
|
根据 `issue-number` 更新指定 issue。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Update issue
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'update-issue'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
state: 'open'
|
||||||
|
title: 'xxx'
|
||||||
|
body: 'xxxx'
|
||||||
|
update-mode: 'replace'
|
||||||
|
labels: 'xx'
|
||||||
|
assignees: 'xxx'
|
||||||
|
contents: '+1'
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
| state | 修改 issue 的状态,可选值 `open` `closed` | string | ✖ | v1 |
|
||||||
|
| title | 修改 issue 的标题 | string | ✖ | v1 |
|
||||||
|
| body | 修改 issue 的内容 | string | ✖ | v1 |
|
||||||
|
| labels | 修改 issue 的 labels | string \| string\[] | ✖ | v1 |
|
||||||
|
| assignees | 修改 issue 的 assignees | string \| string\[] | ✖ | v1 |
|
||||||
|
| contents | 为修改的 issue 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
|
- `state` 默认为 `open`
|
||||||
|
- 当可选项不填时,会保持原有
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
### ⭐ 进 阶
|
||||||
|
|
||||||
|
### ⭐ 高 级
|
||||||
|
|
||||||
|
## 🎁 参 考
|
||||||
|
|
||||||
|
### token
|
||||||
|
|
||||||
|
需拥有 push 权限的人员 token。
|
||||||
|
|
||||||
|
- [个人 token 申请](https://github.com/settings/tokens)
|
||||||
|
- 需勾选 `Full control of private repositories`
|
||||||
|
- 项目添加 secrets
|
||||||
|
- 选择 settings,选择 secrets,选择 `New repository secret`
|
||||||
|
- `Name` 与 actions 中保持一致
|
||||||
|
- `Value` 填写刚才个人申请的 token
|
||||||
|
|
||||||
|
当 actions 不填写 token 时,会默认为 github-actions <kbd>bot</kbd>。适度使用。
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
### 条件判断
|
||||||
|
|
||||||
|
### 触发机制
|
||||||
|
|
||||||
|
- [Workflow syntax for GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
|
||||||
|
- [Events that trigger workflows](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
### Reactions types
|
||||||
|
|
||||||
|
| content | emoji |
|
||||||
|
| -- | -- |
|
||||||
|
| `+1` | 👍 |
|
||||||
|
| `-1` | 👎 |
|
||||||
|
| `laugh` | 😄 |
|
||||||
|
| `confused` | 😕 |
|
||||||
|
| `heart` | ❤️ |
|
||||||
|
| `hooray` | 🎉 |
|
||||||
|
| `rocket` | 🚀 |
|
||||||
|
| `eyes` | 👀 |
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
### `comment_id` 获取
|
||||||
|
|
||||||
|
点击某个评论右上角 `···` 图标,选择 `Copy link`,url 末尾数字即是 `comment_id`。
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
## 谁在使用?
|
||||||
|
|
||||||
|
## LICENSE
|
||||||
|
|
||||||
|
[MIT](https://github.com/actions-cool/issue-helper/blob/main/LICENSE)
|
||||||
|
123
src/base.js
123
src/base.js
@@ -86,7 +86,7 @@ async function doCreateIssue (owner, repo, title, body, labels, assignees) {
|
|||||||
labels
|
labels
|
||||||
};
|
};
|
||||||
if (typeof(assignees) === 'string') {
|
if (typeof(assignees) === 'string') {
|
||||||
params.assignee = assignees;
|
params.assignees.push(assignees);
|
||||||
} else {
|
} else {
|
||||||
params.assignees = assignees;
|
params.assignees = assignees;
|
||||||
}
|
}
|
||||||
@@ -170,63 +170,6 @@ async function doUnlockIssue (owner, repo, issueNumber) {
|
|||||||
core.info(`Actions: [unlock-issue][${issueNumber}] success!`);
|
core.info(`Actions: [unlock-issue][${issueNumber}] success!`);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function doUpdateIssue (
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issueNumber,
|
|
||||||
state,
|
|
||||||
title,
|
|
||||||
body,
|
|
||||||
updateMode,
|
|
||||||
assignees,
|
|
||||||
labels
|
|
||||||
) {
|
|
||||||
const issue = await octokit.issues.get({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number: issueNumber
|
|
||||||
})
|
|
||||||
const issue_body = issue.data.body;
|
|
||||||
const issue_title = issue.data.title;
|
|
||||||
const issue_labels = issue.data.labels;
|
|
||||||
|
|
||||||
let params = {
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number: issueNumber,
|
|
||||||
state
|
|
||||||
};
|
|
||||||
|
|
||||||
params.title = core.getInput("title") ? title : issue_title;
|
|
||||||
|
|
||||||
let next_body;
|
|
||||||
if (core.getInput("body")) {
|
|
||||||
if (updateMode === 'append') {
|
|
||||||
next_body = `${issue_body}\n${body}`;
|
|
||||||
} else {
|
|
||||||
next_body = body;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
next_body = issue_body;
|
|
||||||
}
|
|
||||||
params.body = next_body;
|
|
||||||
|
|
||||||
if (typeof(assignees) === 'string') {
|
|
||||||
params.assignee = assignees;
|
|
||||||
} else {
|
|
||||||
params.assignees = assignees;
|
|
||||||
}
|
|
||||||
|
|
||||||
params.labels = labels ? labels : issue_labels;
|
|
||||||
|
|
||||||
await octokit.issues.update(params);
|
|
||||||
core.info(`Actions: [update-issue][${issueNumber}] success!`);
|
|
||||||
|
|
||||||
if (contents) {
|
|
||||||
await doCreateIssueContent(owner, repo, issueNumber, contents);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
async function doUpdateComment (
|
async function doUpdateComment (
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -261,6 +204,69 @@ async function doUpdateComment (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function doUpdateIssue (
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issueNumber,
|
||||||
|
state,
|
||||||
|
title,
|
||||||
|
body,
|
||||||
|
updateMode,
|
||||||
|
assignees,
|
||||||
|
labels
|
||||||
|
) {
|
||||||
|
const issue = await octokit.issues.get({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: issueNumber
|
||||||
|
})
|
||||||
|
const issue_body = issue.data.body;
|
||||||
|
const issue_title = issue.data.title;
|
||||||
|
const issue_labels = issue.data.labels;
|
||||||
|
const issue_assignees = issue.data.assignees;
|
||||||
|
|
||||||
|
let params = {
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
state
|
||||||
|
};
|
||||||
|
|
||||||
|
params.title = core.getInput("title") ? title : issue_title;
|
||||||
|
|
||||||
|
let next_body;
|
||||||
|
if (core.getInput("body")) {
|
||||||
|
if (updateMode === 'append') {
|
||||||
|
next_body = `${issue_body}\n${body}`;
|
||||||
|
} else {
|
||||||
|
next_body = body;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
next_body = issue_body;
|
||||||
|
}
|
||||||
|
params.body = next_body;
|
||||||
|
|
||||||
|
if (core.getInput("assignees")) {
|
||||||
|
if (typeof(assignees) === 'string') {
|
||||||
|
params.assignees.push(assignees);
|
||||||
|
} else {
|
||||||
|
params.assignees = assignees;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
params.assignees = issue_assignees;
|
||||||
|
}
|
||||||
|
|
||||||
|
params.labels = labels ? labels : issue_labels;
|
||||||
|
|
||||||
|
await octokit.issues.update(params);
|
||||||
|
core.info(`Actions: [update-issue][${issueNumber}] success!`);
|
||||||
|
|
||||||
|
if (contents) {
|
||||||
|
await doCreateIssueContent(owner, repo, issueNumber, contents);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// tool
|
||||||
function testContent(con) {
|
function testContent(con) {
|
||||||
if (ALLREACTIONS.includes(con)) {
|
if (ALLREACTIONS.includes(con)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -270,6 +276,7 @@ function testContent(con) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// exports
|
||||||
module.exports = {
|
module.exports = {
|
||||||
doAddAssignees,
|
doAddAssignees,
|
||||||
doAddLabels,
|
doAddLabels,
|
||||||
|
24
src/main.js
24
src/main.js
@@ -27,8 +27,8 @@ const ALLACTIONS = [
|
|||||||
'remove-assignees',
|
'remove-assignees',
|
||||||
'set-labels',
|
'set-labels',
|
||||||
'unlock-issue',
|
'unlock-issue',
|
||||||
'update-issue',
|
|
||||||
'update-comment',
|
'update-comment',
|
||||||
|
'update-issue',
|
||||||
];
|
];
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -47,9 +47,9 @@ async function main() {
|
|||||||
const assignees = core.getInput("assignees");
|
const assignees = core.getInput("assignees");
|
||||||
|
|
||||||
const labels = core.getInput("labels");
|
const labels = core.getInput("labels");
|
||||||
const state = core.getInput("state");
|
const state = core.getInput("state") || 'open';
|
||||||
|
|
||||||
let updateMode = core.getInput("state") || 'replace';
|
let updateMode = core.getInput("update-mode") || 'replace';
|
||||||
if (updateMode !== 'append') {
|
if (updateMode !== 'append') {
|
||||||
updateMode = 'replace';
|
updateMode = 'replace';
|
||||||
}
|
}
|
||||||
@@ -101,6 +101,15 @@ async function main() {
|
|||||||
case 'unlock-issue':
|
case 'unlock-issue':
|
||||||
await doUnlockIssue(owner, repo, issueNumber);
|
await doUnlockIssue(owner, repo, issueNumber);
|
||||||
break;
|
break;
|
||||||
|
case 'update-comment':
|
||||||
|
await doUpdateComment(
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
commentId,
|
||||||
|
body,
|
||||||
|
updateMode
|
||||||
|
);
|
||||||
|
break;
|
||||||
case 'update-issue':
|
case 'update-issue':
|
||||||
await doUpdateIssue(
|
await doUpdateIssue(
|
||||||
owner,
|
owner,
|
||||||
@@ -113,14 +122,7 @@ async function main() {
|
|||||||
assignees,
|
assignees,
|
||||||
labels
|
labels
|
||||||
);
|
);
|
||||||
case 'update-comment':
|
break;
|
||||||
await doUpdateComment(
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
commentId,
|
|
||||||
body,
|
|
||||||
updateMode
|
|
||||||
);
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user