Compare commits

...

43 Commits
v1.7 ... v2.1.1

Author SHA1 Message Date
xrkffgg
f743eedacb chore: add catch (#59)
* chore: add catch

* format
2021-02-03 09:28:14 +08:00
xrkffgg
65461c17ed docs: update v2.1.1 (#58) 2021-02-03 00:45:14 +08:00
xrkffgg
1efbf3d3cf fix: api request limit (#57) 2021-02-03 00:34:17 +08:00
xrkffgg
14e4762bf5 docs: up v2.1.0 2021-02-02 20:38:24 +08:00
xrkffgg
fd3eb6dbd3 feat: add create-label (#54)
* feat: add create-label

* add doc

* format

* add
2021-02-02 20:33:00 +08:00
xrkffgg
561193570f up 2021-02-02 20:32:37 +08:00
xrkffgg
f2288b2a14 add 2021-02-02 20:22:50 +08:00
xrkffgg
4281108d01 format 2021-02-02 20:22:38 +08:00
xrkffgg
1cc6f0b7ca add doc 2021-02-02 20:12:42 +08:00
xrkffgg
f6788d2b8e feat: add create-label 2021-02-02 17:55:54 +08:00
xrkffgg
8acd7991df docs: add token trigger note 2021-02-01 10:03:25 +08:00
xrkffgg
321da097ae Create gh-pages.yml 2021-01-28 15:25:47 +08:00
xrkffgg
13e635fb2c docs: up version faq 2021-01-27 11:25:01 +08:00
xrkffgg
ae8b2ad0bd docs: update version desc 2021-01-27 11:17:46 +08:00
xrkffgg
576d7c4cb8 docs: up version v2 (#52) 2021-01-26 23:17:43 +08:00
xrkffgg
b0e25793f1 refactor: add require-permission default (#51) 2021-01-26 22:59:37 +08:00
xrkffgg
eb91801d3e docs: update changelog 1.12 2021-01-26 22:24:40 +08:00
xrkffgg
616c112b12 feat: add lock-reason (#49)
* feat: add lock-reason

* add dist
2021-01-26 22:17:55 +08:00
xrkffgg
1425c335af refactor: rename allow-permissions (#48)
* refactor: rename allow-permissions

* up
2021-01-26 21:50:10 +08:00
xrkffgg
f777971d6d feat: add allow-permissions (#46)
* feat: add

* up

* up

* add doc
2021-01-26 17:55:42 +08:00
xrkffgg
4c5e1fa83c Update ci.yml 2021-01-26 15:40:09 +08:00
xrkffgg
dcad795964 chore: add prettier (#45)
* chore: add prettier

* add badge

* up
2021-01-26 15:38:25 +08:00
xrkffgg
37632245d8 docs: add users 2021-01-22 15:53:33 +08:00
xrkffgg
9018700e94 docs: add users (#44)
* docs: add users

* fix
2021-01-18 09:54:18 +08:00
xrkffgg
11acd15e70 docs: update version (#43) 2021-01-14 10:41:25 +08:00
xrkffgg
7619e79b94 perf: expand duplicate action (#40)
* perf: expand duplicate action

* up
2021-01-13 11:08:56 +08:00
xrkffgg
c7cf5de709 feat: add question mark duplicate (#38)
* feat: add question mark duplicate

* add package

* add

* up

* up
2021-01-13 09:32:46 +08:00
xrkffgg
273b6abb78 docs: update version Introduction (#37)
* docs: update version Introduction

* add less
2021-01-12 18:12:11 +08:00
xrkffgg
87bca14eb5 fix: duplicate labels set (#36)
* fix: duplicate labels set

* up version

* add labels

* add

* perf map

* fix set

* add info

* avoid setLabels

* change for

* refactor setLabels

* fix

* change info loca

* fix

* fix
2021-01-12 17:05:24 +08:00
xrkffgg
8e05706e43 feat: add random to (#35)
* feat: add random to

* add actions

* up

* up version

* add less
2021-01-11 21:32:00 +08:00
xrkffgg
3836013160 docs: add users (#34) 2021-01-09 17:35:04 +08:00
xrkffgg
fd98f44d05 docs: update users (#33)
* docs: update users

* fix link

* up
2021-01-09 11:36:23 +08:00
xrkffgg
0396471168 docs: perf website (#32) 2021-01-08 11:09:23 +08:00
xrkffgg
b7db679f4b docs: update doc 2021-01-07 17:41:52 +08:00
xrkffgg
0cbadbacfa chore: update dist 2021-01-07 17:35:01 +08:00
xrkffgg
1ce7be88a0 Delete check-dist.yml 2021-01-07 17:31:42 +08:00
xrkffgg
53dda7f0e4 🤖 auto: updated dist 2021-01-07 09:15:22 +00:00
xrkffgg
026e812e04 refactor: split content & add remove labels (#31)
* refactor: split content & add remove labels

* add

* add

* opt inactive check

* up web

* addadd

* change version

* add style

* add less
2021-01-07 17:14:32 +08:00
xrkffgg
986730477b docs: add users (#30)
* docs: add users

* add

* add
2021-01-05 20:29:09 +08:00
xrkffgg
9984ee0402 🤖 auto: updated dist 2021-01-04 05:57:39 +00:00
xrkffgg
dae9d88636 docs: optimize website (#29)
* docs: optimize website

* a

* a
2021-01-04 13:56:48 +08:00
xrkffgg
7879d79201 chore: remove no use 2021-01-03 11:21:21 +08:00
xrkffgg
ed1da6607e docs: fix typo 2021-01-02 23:13:46 +08:00
46 changed files with 17622 additions and 1997 deletions

View File

@@ -8,11 +8,11 @@ First of all, thank you for your contribution! 😄
- [ ] 新特性提交 / New feature
- [ ] bug 修复 / Fix bug
- [ ] 样式优化 / Style optimization
- [ ] 包体积优化 / Package size optimization
- [ ] 性能优化 / Performance optimization
- [ ] 代码风格优化 / Code style optimization
- [ ] 性能优化 / Performance optimization
- [ ] 构建优化 / Build optimization
- [ ] 网站、文档、Demo 改进 / Website, documentation, demo improvements
- [ ] 重构代码或样式 / Refactor code or style
- [ ] 测试相关 / Test related
- [ ] 其他 / Other
@@ -42,7 +42,6 @@ Describe changes from the user side, and list all potential break changes or oth
| 🇺🇸 English | |
| 🇨🇳 Chinese | |
### ☑️ 请求合并前的自查清单 / Self Check before Merge
⚠️ 请自检并全部**勾选全部选项**。/ Please check all items below before review. ⚠️

View File

@@ -1,27 +0,0 @@
name: Update dist
on:
push:
branches: [ main ]
jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: install
run: yarn
- name: package
run: yarn package
- name: Commit and push if changed
run: |-
git diff
git config --global user.email "xrkffgg@vip.qq.com"
git config --global user.name "xrkffgg"
git pull
git add -A
git commit -m "🤖 auto: updated dist" || exit 0
git push

View File

@@ -11,6 +11,9 @@ jobs:
- name: install
run: yarn install
- name: format
run: yarn format-check
- name: package
run: yarn package

17
.github/workflows/gh-pages.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: github pages
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm run docs:build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs-dist

2
.gitignore vendored
View File

@@ -18,7 +18,7 @@ yarn-error.log*
# dependencies
node_modules
yarn.lock
# yarn.lock
package-lock.json
# local env files

5
.prettierignore Normal file
View File

@@ -0,0 +1,5 @@
dist/
lib/
docs-dist/
node_modules/
src/.umi/

6
.prettierrc.js Normal file
View File

@@ -0,0 +1,6 @@
const fabric = require('@umijs/fabric');
module.exports = {
...fabric.prettier,
arrowParens: 'avoid',
};

View File

@@ -1,4 +1,4 @@
export default {
base: '/',
publicPath: '/'
publicPath: '/',
};

View File

@@ -6,10 +6,8 @@ const name = 'issues-helper';
export default defineConfig({
title: 'Issue Helper',
mode: 'site',
favicon:
'https://avatars1.githubusercontent.com/u/73879334?s=200&v=4',
logo:
'https://avatars1.githubusercontent.com/u/73879334?s=200&v=4',
favicon: 'https://avatars1.githubusercontent.com/u/73879334?s=200&v=4',
logo: 'https://avatars1.githubusercontent.com/u/73879334?s=200&v=4',
exportStatic: {},
ssr: {},
outputPath: 'docs-dist',
@@ -21,7 +19,7 @@ export default defineConfig({
['en-US', 'English'],
],
theme: {
'@c-primary': '#42a5f5',
'@c-primary': '#1890ff',
},
navs: {
'zh-CN': [
@@ -38,7 +36,7 @@ export default defineConfig({
{ title: 'Advanced', path: '/en-US/advanced' },
{ title: 'Changelog', path: '/en-US/changelog' },
{ title: 'GitHub', path: 'https://github.com/actions-cool/issues-helper' },
]
],
},
menus: {
'/guide': [
@@ -47,9 +45,13 @@ export default defineConfig({
children: ['/guide/index', '/guide/start'],
},
{
title: '🎁 参 考',
title: '🎁 参 考',
path: '/guide/ref',
},
{
title: '🎗 记 录',
path: '/guide/note',
},
{
title: '💬 FAQ',
path: '/guide/faq',
@@ -61,20 +63,17 @@ export default defineConfig({
children: ['/guide/index', '/guide/start'],
},
{
title: '🎁 Reference',
title: '🎁 Reference',
path: '/guide/ref',
},
{
title: '🎗 Note',
path: '/guide/note',
},
{
title: '💬 FAQ',
path: '/guide/faq',
},
],
},
styles: [
`
.markdown table {
width: auto !important;
}
`,
]
});

View File

@@ -1,3 +1,58 @@
## v2.1.1
`2021.02.03`
- fix: api request limit. [#57](https://github.com/actions-cool/issues-helper/pull/57)
## v2.1.0
`2021.02.02`
- feat: add create-label. [#54](https://github.com/actions-cool/issues-helper/pull/54)
## v2.0.0
`2021.01.26`
- refactor: add require-permission default. [#51](https://github.com/actions-cool/issues-helper/pull/51)
## v1.12
> It will be the last version of 1.x
`2021.01.26`
- feat: add require-permission. [#46](https://github.com/actions-cool/issues-helper/pull/46) [#48](https://github.com/actions-cool/issues-helper/pull/48)
- feat: add lock-reason. [#49](https://github.com/actions-cool/issues-helper/pull/49)
## v1.11
`2021.01.14`
- feat: add question mark duplicate. [#38](https://github.com/actions-cool/issues-helper/pull/38)
- perf: expand duplicate action. [#40](https://github.com/actions-cool/issues-helper/pull/40)
## v1.10
`2021.01.12`
- fix: duplicate labels set. [#36](https://github.com/actions-cool/issues-helper/pull/36)
## v1.9
`2021.01.11`
- feat: add random to. [#35](https://github.com/actions-cool/issues-helper/pull/35)
## v1.8
`2021.01.07`
- [#31](https://github.com/actions-cool/issues-helper/pull/31)
- refactor: split content
- feat: add `remove-labels` for duplicate
- docs: optimize website
## v1.7
`2021.01.02`

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 xrkffgg
Copyright (c) 2020-present xrkffgg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -5,9 +5,11 @@
[![](https://img.shields.io/github/workflow/status/actions-cool/issues-helper/ci?style=flat-square)](https://github.com/actions-cool/issues-helper/actions)
[![](https://img.shields.io/badge/marketplace-issues--helper-red?style=flat-square)](https://github.com/marketplace/actions/issues-helper)
[![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![](https://img.shields.io/github/v/release/actions-cool/issues-helper?style=flat-square&color=orange)](https://github.com/actions-cool/issues-helper/releases)
[![](https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square&color=%2308979c)](https://github.com/actions-cool/issues-helper/discussions)
[![](https://img.shields.io/github/stars/actions-cool/issues-helper?style=flat-square)](https://github.com/actions-cool/issues-helper/stargazers)
[![](https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square&color=%2308979c)](https://github.com/actions-cool/issues-helper/discussions)
[![](https://img.shields.io/github/license/actions-cool/issues-helper?style=flat-square)](https://github.com/actions-cool/issues-helper/blob/main/LICENSE)
A GitHub Action that easily helps you automatically manage issues
@@ -22,6 +24,77 @@ A GitHub Action that easily helps you automatically manage issues
> Private projects have a limit of 2000 times per month. [Specific view](https://github.com/settings/billing). Public are unlimited.
## Who is using?
Please leave a message at [**here**](https://github.com/actions-cool/issues-helper/issues/6).
<table>
<tr>
<td align="center" width="180">
<a href="https://github.com/ant-design/ant-design">
<img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" />
<div>ant-design</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/ant-design-blazor/ant-design-blazor">
<img src="https://raw.githubusercontent.com/ant-design-blazor/ant-design-blazor/7dbee63648e088c73c47eada79c897bc39fc3c26/logo.svg" width="46" />
<div>ant-design-blazor</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/vueComponent/ant-design-vue">
<img src="https://avatars1.githubusercontent.com/u/32120805?s=200&v=4" width="46" />
<div>ant-design-vue</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/umijs/dumi">
<img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" />
<div>dumi</div>
</a></td>
</tr><tr>
<td align="center" width="180">
<a href="https://github.com/mui-org/material-ui">
<img src="https://avatars2.githubusercontent.com/u/33663932?s=200&v=4" width="46" />
<div>material-ui</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/prettier/prettier">
<img src="https://github.com/prettier/prettier-logo/blob/master/images/prettier-icon-light.png?raw=true" width="46" />
<div>prettier</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/ant-design/pro-components">
<img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" />
<div>pro-components</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/react-component">
<img src="https://avatars3.githubusercontent.com/u/9441414?s=200&v=4" width="46" />
<div>react-component</div>
</a></td>
</tr><tr>
<td align="center" width="180">
<a href="https://github.com/lijinke666/react-music-player">
<img src="https://github.com/lijinke666/react-music-player/blob/master/assetsImg/logo.png?raw=true" width="46" />
<div>react-music-player</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/umijs/umi">
<img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" />
<div>umi</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/AttoJS/vue-request">
<img src="https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png" width="46" />
<div>vue-request</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/zoo-js/zoo">
<img src="https://avatars1.githubusercontent.com/u/70757173?s=200&v=4" width="46" />
<div>zoo</div>
</a></td>
</tr>
</table>
## List
When the following list does not have the features you want, you can submit it in [What do you want?](https://github.com/actions-cool/issues-helper/discussions/18).
@@ -32,6 +105,7 @@ When the following list does not have the features you want, you can submit it i
- [`close-issue`](#close-issue)
- [`create-comment`](#create-comment)
- [`create-issue`](#create-issue)
- [`create-label`](#create-label)
- [`delete-comment`](#delete-comment)
- [`lock-issue`](#lock-issue)
- [`mark-duplicate`](#mark-duplicate)
@@ -75,12 +149,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Add assigness
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
assignees: 'xxx' or 'xx1,xx2'
random-to: 1
```
| Param | Desc | Type | Required |
@@ -89,12 +164,13 @@ jobs:
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | ✔ |
| assignees | Designated person. No operation when no input or empty character | string | ✖ |
| random-to | When set, it will be randomly selected in assignees | number | ✖ |
- `actions` support multiple and separated by comma. Like: `add-assignees,add-labels`
- The `name` can be modified according to the actual situation
- [Reference to on](#github-docs)
- `${{ github.event.issue.number }}` is the current issue. [More references](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events)
- `assignees` support multiple and separated by comma
- `assignees` support multiple and separated by comma
⏫ [Back to list](#List)
@@ -115,7 +191,7 @@ jobs:
if: contains(github.event.issue.body, 'xxx') == false
steps:
- name: Add labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -140,7 +216,7 @@ Close the specified issue.
```yml
- name: Close issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -173,7 +249,7 @@ jobs:
if: github.event.label.name == 'xxx'
steps:
- name: Create comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -217,7 +293,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -236,6 +312,7 @@ jobs:
| body | The body of the new issue | string | ✖ |
| labels | The labels for the new issue | string | ✖ |
| assignees | The assignees for the new issue | string | ✖ |
| random-to | When set, it will be randomly selected in assignees | number | ✖ |
| contents | Add [reaction](#reactions-types) | string | ✖ |
- `title` default is `Default Title`
@@ -243,13 +320,41 @@ jobs:
⏫ [Back to list](#List)
#### `create-label`
Create label。If you want to create multiple labels base on repository path. [See](https://github.com/actions-cool/create-labels).
```yml
- name: Create label
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }}
label-name: 'xx'
label-color: '0095b3'
label-desc: 'xx'
```
| Param | Desc | Type | Required |
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| label-name | Label name, emoji support | string | ✔ |
| label-color | Label color, the format is hexadecimal color code, without `#` | string | ✖ |
| label-desc | Label description | string | ✖ |
- `label-name`: If it already exists, no operation
- `label-color`: Default is `ededed`
⏫ [Back to list](#List)
#### `delete-comment`
According to [`comment-id`](#comment-id) delete the specified comment.
```yml
- name: Delete comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'delete-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -281,7 +386,7 @@ jobs:
if: github.event.label.name == 'invalid'
steps:
- name: Lock issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'lock-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -293,26 +398,29 @@ jobs:
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | ✔ |
| lock-reason | Reason for locking issue | string | ✖ |
- `lock-reason`: Optional values are `off-topic` `too heated` `resolved` `spam`
⏫ [Back to list](#List)
#### `mark-duplicate`
Quickly mark duplicate questions, only for issue new comments.
Quickly mark duplicate questions, only for issue new comments or edit comments.
```yml
name: Issue Mark Duplicate
on:
issue_comment:
types: [created]
types: [created, edited]
jobs:
mark-duplicate:
runs-on: ubuntu-latest
steps:
- name: mark-duplicate
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -324,12 +432,20 @@ jobs:
| token | [Token explain](#token) | string | ✔ |
| duplicate-command | Simple commands can be set, such as: `/d` | string | ✖ |
| duplicate-labels | Add additional labels to this issue | string | ✖ |
| remove-labels | Set removable labels | string | ✖ |
| labels | Replace the labels of the issue | string | ✖ |
| contents | Add [reaction](#reactions-types) for this comment | string | ✖ |
| close-issue | Whether to close the issue at the same time | string | ✖ |
| require-permission | Permission required, default is `write` | string | ✖ |
- `duplicate-command`: When setting concise commands, while still supporting the original `Duplicate of`
- `duplicate-command`: When setting concise commands, while still supporting the original `Duplicate of`. Block content contains `?`
- `labels`: Highest priority
- `close-issue`: Both `true` or `'true'` can take effect
- `require-permission`: Optional values are `admin`, `write`, `read`, `none`
- If the team member sets the `read` permission, it is `read`
- If the external Collaborator is set to `read` permission, it is `read`
- Ordinary users have `read` permission
- When set `write`, `admin` and `write` meet the conditions
⏫ [Back to list](#List)
@@ -339,7 +455,7 @@ Open the specified issue.
```yml
- name: Open issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'open-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -360,7 +476,7 @@ Remove the person designated by issue.
```yml
- name: Remove assignees
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'remove-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -383,7 +499,7 @@ Remove the specified labels.
```yml
- name: Remove labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -408,7 +524,7 @@ Replace the labels of issue.
```yml
- name: Set labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'set-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -431,7 +547,7 @@ Unlock the specified issue.
```yml
- name: Unlock issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'unlock-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -464,7 +580,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Update comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -492,7 +608,7 @@ Update the specified issue according to the `issue-number`.
```yml
- name: Update issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -542,7 +658,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: welcome
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'welcome'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -585,7 +701,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check-inactive
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'check-inactive'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -638,7 +754,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check-issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'check-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -657,7 +773,7 @@ jobs:
| body-includes | Body contains check | string | ✖ |
- `title-includes` `body-includes` supports the format `x1,x2` or `x1,x2/y1,y2`. Only supports two levels
- Return `check-result`
- Return `check-result`, due to yml reasons, the judgment condition is `if: steps.xxid.outputs.check-result =='true'`
⏫ [Back to list](#List)
@@ -677,7 +793,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: close-issues
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -711,7 +827,7 @@ Find the current warehouse issue No. 1, the creator is k and the content contain
```yml
- name: Find comments
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -759,7 +875,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: lock-issues
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'lock-issues'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -781,6 +897,7 @@ jobs:
| body-includes | Body filtering | string | ✖ |
| title-includes | Title filtering | string | ✖ |
| inactive-day | Inactive days filtering | number | ✖ |
| lock-reason | Reason for locking issue | string | ✖ |
- `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all
- `issue-state`: The default is `all`. Optional value `open` `closed`, when these 2 items are not, both are `all`
@@ -805,7 +922,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: month-statistics
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -848,7 +965,7 @@ jobs:
if: github.event.label.name == 'watch'
steps:
- name: find comments
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
id: fcid
with:
actions: 'find-comments'
@@ -859,7 +976,7 @@ jobs:
- name: create comment
if: ${{ steps.fcid.outputs.comments.length == 0 }}
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -868,7 +985,7 @@ jobs:
- name: update comment
if: ${{ steps.fcid.outputs.comments.length == 1 }}
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -900,7 +1017,7 @@ When the token is not filled in actions or the corresponding secrets are not add
```yml
- name: Create issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
id: createissue
with:
actions: 'create-issue'
@@ -974,59 +1091,38 @@ Click the `···` icon in the upper right corner of a comment, select `Copy lin
- Use two-level semantic version, such as v1, v1.1, v2, v2.1
- v1 represents the initial version
- The fixes and additions to the v1 version will be released to the v1.1 version
- When the released v1.x runs stable for a certain period of time, release the advanced v2 version
- When the released v1.x runs stable for a certain period of time or undergoes refactoring, release the advanced v2 version
- After the v2 version, the version will be released strictly according to the three-level semantics, such as v2.0.0, v2.1.0
- Version selection
- It is recommended to use the latest releases version. It can be seen in [releases](https://github.com/actions-cool/issues-helper/releases)
- You can also refer to the update log below to select the version
- The latest v1.x release code will be merged into the 1.x branch
- It also supports the direct use of branch versions. Such as:
```yml
- name: Issues Helper
uses: actions-cool/issues-helper@main
# or
- name: Issues Helper
uses: actions-cool/issues-helper@1.x
```
## Actions Template
- You can directly use this [GitHub Actions workflow template](https://github.com/actions-cool/.github) repositorie template
- Personal exercises and tests [Actions](https://github.com/xrkffgg/test-ci) repository
- Can also refer to the warehouse of [online users](#who-is-using)
## 💖 Who is using?
## ⚡ Feedback
You can come to the following repositories for reference. Please leave a message at [**here**](https://github.com/actions-cool/issues-helper/issues/6).
You are very welcome to try it out and put forward your comments. You can use the following methods:
At the same time, if you have any questions during use, you can also ask and inquire in the issue or discussion.
<table>
<tr>
<td align="center"><a href="https://github.com/ant-design/ant-design"><img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" /></a></td>
<td align="center"><a href="https://github.com/vueComponent/ant-design-vue"><img src="https://avatars1.githubusercontent.com/u/32120805?s=200&v=4" width="46" /></a></td>
<td align="center"><a href="https://github.com/umijs/dumi"><img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" /></a></td>
<td align="center"><a href="https://github.com/mui-org/material-ui"><img src="https://avatars2.githubusercontent.com/u/33663932?s=200&v=4" width="46" /></a></td>
<td align="center"><a href="https://github.com/umijs/umi"><img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" /></a></td>
</tr>
<tr>
<td width="160" align="center">ant-design</td>
<td width="160" align="center">ant-design-vue</td>
<td width="160" align="center">dumi</td>
<td width="160" align="center">material-ui</td>
<td width="160" align="center">umi</td>
</tr><tr>
<td align="center"><a href="https://github.com/AttoJS/vue-request"><img src="https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png" width="46" /></a></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td width="160" align="center">vue-request</td>
<td width="160" align="center"></td>
<td width="160" align="center"></td>
<td width="160" align="center"></td>
<td width="160" align="center"></td>
</tr>
</table>
- Report bugs or consult with [Issue](https://github.com/actions-cool/issues-helper/issues)
- Discuss via [Discussions](https://github.com/actions-cool/issues-helper/discussions)
- Submit [Pull Request](https://github.com/actions-cool/issues-helper/pulls) to improve the code of `issues-helper`
## LICENSE

230
README.md
View File

@@ -5,9 +5,11 @@
[![](https://img.shields.io/github/workflow/status/actions-cool/issues-helper/ci?style=flat-square)](https://github.com/actions-cool/issues-helper/actions)
[![](https://img.shields.io/badge/marketplace-issues--helper-red?style=flat-square)](https://github.com/marketplace/actions/issues-helper)
[![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![](https://img.shields.io/github/v/release/actions-cool/issues-helper?style=flat-square&color=orange)](https://github.com/actions-cool/issues-helper/releases)
[![](https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square&color=%2308979c)](https://github.com/actions-cool/issues-helper/discussions)
[![](https://img.shields.io/github/stars/actions-cool/issues-helper?style=flat-square)](https://github.com/actions-cool/issues-helper/stargazers)
[![](https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square&color=%2308979c)](https://github.com/actions-cool/issues-helper/discussions)
[![](https://img.shields.io/github/license/actions-cool/issues-helper?style=flat-square)](https://github.com/actions-cool/issues-helper/blob/main/LICENSE)
一个轻松帮你自动管理 issues 的 GitHub Action
@@ -22,6 +24,77 @@
> Private 项目每月有 2000 次的限制,[具体查看](https://github.com/settings/billing)。Public 项目无限制。
## 谁在使用?
欢迎在 [**这里**](https://github.com/actions-cool/issues-helper/issues/6) 留言。
<table>
<tr>
<td align="center" width="180">
<a href="https://github.com/ant-design/ant-design">
<img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" />
<div>ant-design</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/ant-design-blazor/ant-design-blazor">
<img src="https://raw.githubusercontent.com/ant-design-blazor/ant-design-blazor/7dbee63648e088c73c47eada79c897bc39fc3c26/logo.svg" width="46" />
<div>ant-design-blazor</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/vueComponent/ant-design-vue">
<img src="https://avatars1.githubusercontent.com/u/32120805?s=200&v=4" width="46" />
<div>ant-design-vue</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/umijs/dumi">
<img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" />
<div>dumi</div>
</a></td>
</tr><tr>
<td align="center" width="180">
<a href="https://github.com/mui-org/material-ui">
<img src="https://avatars2.githubusercontent.com/u/33663932?s=200&v=4" width="46" />
<div>material-ui</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/prettier/prettier">
<img src="https://github.com/prettier/prettier-logo/blob/master/images/prettier-icon-light.png?raw=true" width="46" />
<div>prettier</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/ant-design/pro-components">
<img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" />
<div>pro-components</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/react-component">
<img src="https://avatars3.githubusercontent.com/u/9441414?s=200&v=4" width="46" />
<div>react-component</div>
</a></td>
</tr><tr>
<td align="center" width="180">
<a href="https://github.com/lijinke666/react-music-player">
<img src="https://github.com/lijinke666/react-music-player/blob/master/assetsImg/logo.png?raw=true" width="46" />
<div>react-music-player</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/umijs/umi">
<img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" />
<div>umi</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/AttoJS/vue-request">
<img src="https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png" width="46" />
<div>vue-request</div>
</a></td>
<td align="center" width="180">
<a href="https://github.com/zoo-js/zoo">
<img src="https://avatars1.githubusercontent.com/u/70757173?s=200&v=4" width="46" />
<div>zoo</div>
</a></td>
</tr>
</table>
## 列 表
当以下列表没有你想要的功能时,可以在 [What do you want?](https://github.com/actions-cool/issues-helper/discussions/18) 中提出。
@@ -32,6 +105,7 @@
- [`close-issue`](#close-issue)
- [`create-comment`](#create-comment)
- [`create-issue`](#create-issue)
- [`create-label`](#create-label)
- [`delete-comment`](#delete-comment)
- [`lock-issue`](#lock-issue)
- [`mark-duplicate`](#mark-duplicate)
@@ -75,12 +149,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Add assigness
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
assignees: 'xxx' or 'xx1,xx2'
random-to: 1
```
| 参数 | 描述 | 类型 | 必填 |
@@ -89,6 +164,7 @@ jobs:
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | ✔ |
| assignees | 指定人。当不填或者为空字符时,不操作 | string | ✖ |
| random-to | 当设置时,会在 assignees 中随机选择 | number | ✖ |
- `actions` 支持多个,需用逗号隔开。如:`add-assignees,add-labels`
- 其中的 `name` 可根据自行根据实际情况修改
@@ -115,7 +191,7 @@ jobs:
if: contains(github.event.issue.body, 'xxx') == false
steps:
- name: Add labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -140,7 +216,7 @@ jobs:
```yml
- name: Close issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -173,7 +249,7 @@ jobs:
if: github.event.label.name == 'xxx'
steps:
- name: Create comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -217,7 +293,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -236,6 +312,7 @@ jobs:
| body | 新增 issue 的内容 | string | ✖ |
| labels | 为新增 issue 添加 labels | string | ✖ |
| assignees | 为新增 issue 添加 assignees | string | ✖ |
| random-to | 当设置时,会在 assignees 中随机选择 | number | ✖ |
| contents | 为新增 issue 增加 [reaction](#reactions-types) | string | ✖ |
- `title` 默认为:`Default Title`
@@ -243,13 +320,41 @@ jobs:
⏫ [返回列表](#列-表)
#### `create-label`
新增 label。若想根据目录生成多个 labels[可查看](https://github.com/actions-cool/create-labels)。
```yml
- name: Create label
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }}
label-name: 'xx'
label-color: '0095b3'
label-desc: 'xx'
```
| 参数 | 描述 | 类型 | 必填 |
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| label-name | 标签名称,支持 emoji | string | ✔ |
| label-color | 标签颜色,格式为 16 进制色码,不加 `#` | string | ✖ |
| label-desc | 标签描述 | string | ✖ |
- `label-name`:若已存在,则无操作
- `label-color`:默认为 `ededed`
⏫ [返回列表](#列-表)
#### `delete-comment`
根据 [`comment-id`](#comment-id) 删除指定评论。
```yml
- name: Delete comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'delete-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -281,7 +386,7 @@ jobs:
if: github.event.label.name == 'invalid'
steps:
- name: Lock issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'lock-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -293,26 +398,29 @@ jobs:
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | ✔ |
| lock-reason | 锁定 issue 的原因 | string | ✖ |
- `lock-reason`:可选值有 `off-topic` `too heated` `resolved` `spam`
⏫ [返回列表](#列-表)
#### `mark-duplicate`
快捷标记重复问题,仅作用于 issue 新增评论。
快捷标记重复问题,仅作用于 issue 新增编辑评论。
```yml
name: Issue Mark Duplicate
on:
issue_comment:
types: [created]
types: [created, edited]
jobs:
mark-duplicate:
runs-on: ubuntu-latest
steps:
- name: mark-duplicate
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -324,12 +432,20 @@ jobs:
| token | [token 说明](#token) | string | ✔ |
| duplicate-command | 可设置简洁命令,如:`/d` | string | ✖ |
| duplicate-labels | 为该 issue 额外增加 labels | string | ✖ |
| remove-labels | 设置可移除的 labels | string | ✖ |
| labels | 替换该 issue 的 labels | string | ✖ |
| contents | 为该评论的增加 [reaction](#reactions-types) | string | ✖ |
| close-issue | 是否同时关闭该 issue | string | ✖ |
| require-permission | 要求权限,默认为 `write` | string | ✖ |
- `duplicate-command`:当设置简洁命令时,同时仍支持原有 `Duplicate of`
- `duplicate-command`:当设置简洁命令时,同时仍支持原有 `Duplicate of`。屏蔽内容包含 `?`
- `labels`:优先级最高
- `close-issue``true``'true'` 均可生效
- `require-permission`:可选值有 `admin``write``read``none`
- 团队成员若设置 `read` 权限,则为 `read`
- 外部 Collaborator 若设置 `read` 权限,则为 `read`
- 普通用户为 `read` 权限
- 当设置 `write` 后,`admin``write` 满足条件
⏫ [返回列表](#列-表)
@@ -339,7 +455,7 @@ jobs:
```yml
- name: Open issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'open-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -360,7 +476,7 @@ jobs:
```yml
- name: Remove assignees
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'remove-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -383,7 +499,7 @@ jobs:
```yml
- name: Remove labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -408,7 +524,7 @@ jobs:
```yml
- name: Set labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'set-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -431,7 +547,7 @@ jobs:
```yml
- name: Unlock issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'unlock-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -464,7 +580,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Update comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -492,7 +608,7 @@ jobs:
```yml
- name: Update issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -540,7 +656,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: welcome
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'welcome'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -583,7 +699,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check-inactive
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'check-inactive'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -632,7 +748,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check-issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'check-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -651,7 +767,7 @@ jobs:
| body-includes | 内容包含校验 | string | ✖ |
- `title-includes` `body-includes` 支持格式 `x1,x2` 或者 `x1,x2/y1,y2`。只支持两个层级
- 返回 `check-result`
- 返回 `check-result`,由于 yml 原因,判断条件为 `if: steps.xxid.outputs.check-result == 'true'`
⏫ [返回列表](#列-表)
@@ -671,7 +787,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: close-issues
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -705,7 +821,7 @@ jobs:
```yml
- name: Find comments
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -753,7 +869,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: lock-issues
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'lock-issues'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -775,6 +891,7 @@ jobs:
| body-includes | 包含内容筛选 | string | ✖ |
| title-includes | 包含标题筛选 | string | ✖ |
| inactive-day | 非活跃天数筛选 | number | ✖ |
| lock-reason | 锁定 issue 的原因 | string | ✖ |
- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
- `issue-state`:默认为 `open`。可选值 `all` `closed`,非这 2 项时,均为 `open`
@@ -799,7 +916,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: month-statistics
uses: actions-cool/issues-helper@v1.7.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -842,7 +959,7 @@ jobs:
if: github.event.label.name == 'watch'
steps:
- name: find comments
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
id: fcid
with:
actions: 'find-comments'
@@ -853,7 +970,7 @@ jobs:
- name: create comment
if: ${{ steps.fcid.outputs.comments.length == 0 }}
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -862,7 +979,7 @@ jobs:
- name: update comment
if: ${{ steps.fcid.outputs.comments.length == 1 }}
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -894,7 +1011,7 @@ jobs:
```yml
- name: Create issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
id: createissue
with:
actions: 'create-issue'
@@ -969,59 +1086,38 @@ x2 + y2
- 采用两级语义化版本如v1、v1.1、v2、v2.1
- v1 表示初始版本
- 对 v1 版本的修复和新增会发布到 v1.1 版本
- 当发布的 v1.x 运行一定时间稳定,发布进阶 v2 版本
- 当发布的 v1.x 运行一定时间稳定或进行重构时,发布进阶 v2 版本
- v2 版本后会严格按照三级语义来发布版本,如 v2.0.0、v2.1.0
- 版本选择
- 建议采用最新 releases 版本。可在 [releases](https://github.com/actions-cool/issues-helper/releases) 看到
- 同时也可参照下面的更新日志来选择版本
- 也支持直接使用分支版本。如:
- 最新的 v1.x release 代码会合并到 1.x 分支中
- 支持直接使用分支版本。如:
```yml
- name: Issues Helper
uses: actions-cool/issues-helper@main
# or
- name: Issues Helper
uses: actions-cool/issues-helper@1.x
```
## Actions 模板
- 可直接使用这个 [GitHub Actions workflow template](https://github.com/actions-cool/.github) 仓库的模板
- 个人练习和测试 [Actions](https://github.com/xrkffgg/test-ci) 的仓库
- 也可以来 [线上使用者](#谁在使用) 的仓库参照
## 💖 谁在使用?
## ⚡ 反馈
你可以来以下项目进行参考。欢迎在 [**这里**](https://github.com/actions-cool/issues-helper/issues/6) 留言。
非常欢迎你来尝试使用,并提出意见,你可以通过以下方式:
同时,如果你在使用过程中有什么疑问,也可以在 issue 或者 discussion 中进行提问和查询。
<table>
<tr>
<td align="center"><a href="https://github.com/ant-design/ant-design"><img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" /></a></td>
<td align="center"><a href="https://github.com/vueComponent/ant-design-vue"><img src="https://avatars1.githubusercontent.com/u/32120805?s=200&v=4" width="46" /></a></td>
<td align="center"><a href="https://github.com/umijs/dumi"><img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" /></a></td>
<td align="center"><a href="https://github.com/mui-org/material-ui"><img src="https://avatars2.githubusercontent.com/u/33663932?s=200&v=4" width="46" /></a></td>
<td align="center"><a href="https://github.com/umijs/umi"><img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" /></a></td>
</tr>
<tr>
<td width="160" align="center">ant-design</td>
<td width="160" align="center">ant-design-vue</td>
<td width="160" align="center">dumi</td>
<td width="160" align="center">material-ui</td>
<td width="160" align="center">umi</td>
</tr><tr>
<td align="center"><a href="https://github.com/AttoJS/vue-request"><img src="https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png" width="46" /></a></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td width="160" align="center">vue-request</td>
<td width="160" align="center"></td>
<td width="160" align="center"></td>
<td width="160" align="center"></td>
<td width="160" align="center"></td>
</tr>
</table>
- 通过 [Issue](https://github.com/actions-cool/issues-helper/issues) 报告 bug 或进行咨询
- 通过 [Discussions](https://github.com/actions-cool/issues-helper/discussions) 进行讨论
- 提交 [Pull Request](https://github.com/actions-cool/issues-helper/pulls) 改进 `issues-helper` 的代码
## LICENSE

59
USERS.js Normal file
View File

@@ -0,0 +1,59 @@
// **************************************************************************
// Add to end
const users = [
{
url: 'https://github.com/ant-design/ant-design',
logo: 'https://avatars1.githubusercontent.com/u/12101536?s=200&v=4'
},
{
url: 'https://github.com/vueComponent/ant-design-vue',
logo: 'https://avatars1.githubusercontent.com/u/32120805?s=200&v=4'
},
{
url: 'https://github.com/umijs/dumi',
logo: 'https://avatars1.githubusercontent.com/u/33895495?s=200&v=4'
},
{
url: 'https://github.com/umijs/umi',
logo: 'https://avatars1.githubusercontent.com/u/33895495?s=200&v=4'
},
{
url: 'https://github.com/AttoJS/vue-request',
logo: 'https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png'
},
{
url: 'https://github.com/mui-org/material-ui',
logo: 'https://avatars2.githubusercontent.com/u/33663932?s=200&v=4'
},
{
url: 'https://github.com/lijinke666/react-music-player',
logo: 'https://github.com/lijinke666/react-music-player/blob/master/assetsImg/logo.png?raw=true'
},
{
url: 'https://github.com/ant-design-blazor/ant-design-blazor',
logo: 'https://raw.githubusercontent.com/ant-design-blazor/ant-design-blazor/7dbee63648e088c73c47eada79c897bc39fc3c26/logo.svg'
},
{
url: 'https://github.com/zoo-js/zoo',
logo: 'https://avatars1.githubusercontent.com/u/70757173?s=200&v=4'
},
{
url: 'https://github.com/react-component',
logo: 'https://avatars3.githubusercontent.com/u/9441414?s=200&v=4'
},
{
url: 'https://github.com/ant-design/pro-components',
logo: 'https://avatars1.githubusercontent.com/u/12101536?s=200&v=4'
},
{
url: 'https://github.com/prettier/prettier',
logo: 'https://github.com/prettier/prettier-logo/blob/master/images/prettier-icon-light.png?raw=true'
},
];
// **************************************************************************
module.exports = {
users
};
// **************************************************************************

View File

@@ -20,8 +20,18 @@ inputs:
description: 'Issue title'
assignees:
description: 'Issue assignees'
random-to:
description: 'Issue assignees random to'
# label
labels:
description: 'Issue labels'
label-name:
description: 'Create label name'
label-color:
description: 'Create label color, default #ededed'
label-desc:
description: 'Create label description'
state:
description: 'Issue state'
update-mode:
@@ -50,12 +60,18 @@ inputs:
description: 'Query use'
inactive-day:
description: 'Query use'
lock-reason:
description: 'The reason lock issue'
inactive-label:
description: 'Issue label set use'
duplicate-command:
description: 'For mark-duplicate'
duplicate-labels:
description: 'For mark-duplicate add labels'
require-permission:
description: 'Only the allow can do. Possible admin, write, read, and none.'
remove-labels:
description: 'For remove labels'
close-issue:
description: 'For mark-duplicate'
count-lables:

3218
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check-inactive
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'check-inactive'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check-issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'check-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -92,7 +92,7 @@ jobs:
| body-includes | Body contains check | string | ✖ |
- `title-includes` `body-includes` supports the format `x1,x2` or `x1,x2/y1,y2`. Only supports two levels
- Return `check-result`
- Return `check-result`, due to yml reasons, the judgment condition is `if: steps.xxid.outputs.check-result =='true'`
## `close-issues`
@@ -110,7 +110,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: close-issues
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -142,7 +142,7 @@ Find the current warehouse issue No. 1, the creator is k and the content contain
```yml
- name: Find comments
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -188,7 +188,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: lock-issues
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'lock-issues'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -210,6 +210,7 @@ jobs:
| body-includes | Body filtering | string | ✖ |
| title-includes | Title filtering | string | ✖ |
| inactive-day | Inactive days filtering | number | ✖ |
| lock-reason | Reason for locking issue | string | ✖ |
- `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all
- `issue-state`: The default is `all`. Optional value `open` `closed`, when these 2 items are not, both are `all`
@@ -232,7 +233,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: month-statistics
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -251,3 +252,7 @@ jobs:
- The new issue title defaults to `[Current repo] Month Statistics: Year-Month`
- `count-lables`: You can set `'true'` to add labels statistics
- `count-comments`: You can set `'true'` to add comments statistics
As follows:
![](../public/month.png)

View File

@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check-inactive
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'check-inactive'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -69,7 +69,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check-issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'check-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -88,7 +88,7 @@ jobs:
| body-includes | 内容包含校验 | string | ✖ |
- `title-includes` `body-includes` 支持格式 `x1,x2` 或者 `x1,x2/y1,y2`。只支持两个层级
- 返回 `check-result`
- 返回 `check-result`,由于 yml 原因,判断条件为 `if: steps.xxid.outputs.check-result == 'true'`
## `close-issues`
@@ -106,7 +106,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: close-issues
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -138,7 +138,7 @@ jobs:
```yml
- name: Find comments
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -184,7 +184,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: lock-issues
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'lock-issues'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -206,6 +206,7 @@ jobs:
| body-includes | 包含内容筛选 | string | ✖ |
| title-includes | 包含标题筛选 | string | ✖ |
| inactive-day | 非活跃天数筛选 | number | ✖ |
| lock-reason | 锁定 issue 的原因 | string | ✖ |
- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
- `issue-state`:默认为 `all`。可选值 `open` `closed`,非这 2 项时,均为 `all`
@@ -228,7 +229,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: month-statistics
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -238,7 +239,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 |
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明)) | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| labels | 为新增 issue 添加 labels | string | ✖ |
| assignees | 为新增 issue 添加 assignees | string | ✖ |
| count-lables | 新增 issue 是否统计 labels | string | ✖ |
@@ -247,3 +248,7 @@ jobs:
- 新增 `issue` 的标题默认为 `[当前仓库] Month Statistics: 年-月`
- `count-lables`:可设置 `'true'`,增加 labels 统计
- `count-comments`:可设置 `'true'`,增加 comments 统计
如下所示:
![](../public/month.png)

View File

@@ -22,12 +22,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Add assigness
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
assignees: 'xxx' or 'xx1,xx2'
random-to: 1
```
| Param | Desc | Type | Required |
@@ -36,6 +37,7 @@ jobs:
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| issue-number | The number of issue | number | ✔ |
| assignees | Designated person. No operation when no input or empty character | string | ✖ |
| random-to | When set, it will be randomly selected in assignees | number | ✖ |
- `actions` support multiple and separated by comma. Like: `add-assignees,add-labels`
- The `name` can be modified according to the actual situation
@@ -60,7 +62,7 @@ jobs:
if: contains(github.event.issue.body, 'xxx') == false
steps:
- name: Add labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -83,7 +85,7 @@ Close the specified issue.
```yml
- name: Close issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -114,7 +116,7 @@ jobs:
if: github.event.label.name == 'xxx'
steps:
- name: Create comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -156,7 +158,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -175,18 +177,45 @@ jobs:
| body | The body of the new issue | string | ✖ |
| labels | The labels for the new issue | string | ✖ |
| assignees | The assignees for the new issue | string | ✖ |
| random-to | When set, it will be randomly selected in assignees | number | ✖ |
| contents | Add [reaction](/en-US/guide/ref#-reactions-type) | string | ✖ |
- `title` default is `Default Title`
- Return `issue-number`. [Usage reference](/en-US/guide/ref#-outputs-use)
## `create-label`
Create label。If you want to create multiple labels base on repository path. [See](https://github.com/actions-cool/create-labels).
```yml
- name: Create label
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }}
label-name: 'xx'
label-color: '0095b3'
label-desc: 'xx'
```
| Param | Desc | Type | Required |
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| label-name | Label name, emoji support | string | ✔ |
| label-color | Label color, the format is hexadecimal color code, without `#` | string | ✖ |
| label-desc | Label description | string | ✖ |
- `label-name`: If it already exists, no operation
- `label-color`: Default is `ededed`
## `delete-comment`
According to [`comment-id`](/en-US/guide/ref#-comment-id) delete the specified comment.
```yml
- name: Delete comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'delete-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -216,7 +245,7 @@ jobs:
if: github.event.label.name == 'invalid'
steps:
- name: Lock issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'lock-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -228,24 +257,27 @@ jobs:
| actions | Action type | string | ✔ |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| issue-number | The number of issue | number | ✔ |
| lock-reason | Reason for locking issue | string | ✖ |
- `lock-reason`: Optional values are `off-topic` `too heated` `resolved` `spam`
## `mark-duplicate`
Quickly mark duplicate questions, only for issue new comments.
Quickly mark duplicate questions, only for issue new comments or edit comments.
```yml
name: Issue Mark Duplicate
on:
issue_comment:
types: [created]
types: [created, edited]
jobs:
mark-duplicate:
runs-on: ubuntu-latest
steps:
- name: mark-duplicate
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -257,12 +289,20 @@ jobs:
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| duplicate-command | Simple commands can be set, such as: `/d` | string | ✖ |
| duplicate-labels | Add additional labels to this issue | string | ✖ |
| remove-labels | Set removable labels | string | ✖ |
| labels | Replace the labels of the issue | string | ✖ |
| contents | Add [reaction](/en-US/guide/ref#-reactions-type) for this comment | string | ✖ |
| close-issue | Whether to close the issue at the same time | string | ✖ |
| require-permission | Permission required, default is `write` | string | ✖ |
- `duplicate-command`: When setting concise commands, while still supporting the original `Duplicate of`
- `duplicate-command`: When setting concise commands, while still supporting the original `Duplicate of`. Block content contains `?`
- `labels`: Highest priority
- `close-issue`: Both `true` or `'true'` can take effect
- `require-permission`: Optional values are `admin`, `write`, `read`, `none`
- If the team member sets the `read` permission, it is `read`
- If the external Collaborator is set to `read` permission, it is `read`
- Ordinary users have `read` permission
- When set `write`, `admin` and `write` meet the conditions
<Alert>
Note: Duplicate created with the concise command does not display the content of the red box in the figure below. But in fact this has no effect.
@@ -276,7 +316,7 @@ Open the specified issue.
```yml
- name: Open issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'open-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -295,7 +335,7 @@ Remove the person designated by issue.
```yml
- name: Remove assignees
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'remove-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -316,7 +356,7 @@ Remove the specified labels.
```yml
- name: Remove labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -339,7 +379,7 @@ Replace the labels of issue.
```yml
- name: Set labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'set-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -360,7 +400,7 @@ Unlock the specified issue.
```yml
- name: Unlock issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'unlock-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -391,7 +431,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Update comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -417,7 +457,7 @@ Update the specified issue according to the `issue-number`.
```yml
- name: Update issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -465,7 +505,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: welcome
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'welcome'
token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -22,12 +22,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Add assigness
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
assignees: 'xxx' or 'xx1,xx2'
random-to: 1
```
| 参数 | 描述 | 类型 | 必填 |
@@ -36,6 +37,7 @@ jobs:
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| issue-number | 指定的 issue | number | ✔ |
| assignees | 指定人。当不填或者为空字符时,不操作 | string | ✖ |
| random-to | 当设置时,会在 assignees 中随机选择 | number | ✖ |
- `actions` 支持多个,需用逗号隔开。如:`add-assignees,add-labels`
- 其中的 `name` 可根据自行根据实际情况修改
@@ -60,7 +62,7 @@ jobs:
if: contains(github.event.issue.body, 'xxx') == false
steps:
- name: Add labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -83,7 +85,7 @@ jobs:
```yml
- name: Close issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -114,7 +116,7 @@ jobs:
if: github.event.label.name == 'xxx'
steps:
- name: Create comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -156,7 +158,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -175,18 +177,45 @@ jobs:
| body | 新增 issue 的内容 | string | ✖ |
| labels | 为新增 issue 添加 labels | string | ✖ |
| assignees | 为新增 issue 添加 assignees | string | ✖ |
| random-to | 当设置时,会在 assignees 中随机选择 | number | ✖ |
| contents | 为新增 issue 增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ |
- `title` 默认为:`Default Title`
- 返回 `issue-number`[用法参考](/guide/ref#-outputs-使用)
## `create-label`
新增 label。若想根据目录生成多个 labels[可查看](https://github.com/actions-cool/create-labels)。
```yml
- name: Create label
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }}
label-name: 'xx'
label-color: '0095b3'
label-desc: 'xx'
```
| 参数 | 描述 | 类型 | 必填 |
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| label-name | 标签名称,支持 emoji | string | ✔ |
| label-color | 标签颜色,格式为 16 进制色码,不加 `#` | string | ✖ |
| label-desc | 标签描述 | string | ✖ |
- `label-name`:若已存在,则无操作
- `label-color`:默认为 `ededed`
## `delete-comment`
根据 [`comment-id`](/guide/ref#-comment-id) 删除指定评论。
```yml
- name: Delete comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'delete-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -216,7 +245,7 @@ jobs:
if: github.event.label.name == 'invalid'
steps:
- name: Lock issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'lock-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -228,24 +257,27 @@ jobs:
| actions | 操作类型 | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| issue-number | 指定的 issue | number | ✔ |
| lock-reason | 锁定 issue 的原因 | string | ✖ |
- `lock-reason`:可选值有 `off-topic` `too heated` `resolved` `spam`
## `mark-duplicate`
快捷标记重复问题,仅作用于 issue 新增评论。
快捷标记重复问题,仅作用于 issue 新增编辑评论。
```yml
name: Issue Mark Duplicate
on:
issue_comment:
types: [created]
types: [created, edited]
jobs:
mark-duplicate:
runs-on: ubuntu-latest
steps:
- name: mark-duplicate
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -257,12 +289,20 @@ jobs:
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| duplicate-command | 可设置简洁命令,如:`/d` | string | ✖ |
| duplicate-labels | 为该 issue 额外增加 labels | string | ✖ |
| remove-labels | 设置可移除的 labels | string | ✖ |
| labels | 替换该 issue 的 labels | string | ✖ |
| contents | 为该评论的增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ |
| close-issue | 是否同时关闭该 issue | string | ✖ |
| require-permission | 要求权限,默认为 `write` | string | ✖ |
- `duplicate-command`:当设置简洁命令时,同时仍支持原有 `Duplicate of`
- `duplicate-command`:当设置简洁命令时,同时仍支持原有 `Duplicate of`。屏蔽内容包含 `?`
- `labels`:优先级最高
- `close-issue``true``'true'` 均可生效
- `require-permission`:可选值有 `admin``write``read``none`
- 团队成员若设置 `read` 权限,则为 `read`
- 外部 Collaborator 若设置 `read` 权限,则为 `read`
- 普通用户为 `read` 权限
- 当设置 `write` 后,`admin``write` 满足条件
<Alert>
注意:使用简洁命令创建的 Duplicate 不显示下图红框内容。但其实这个没有任何影响的。
@@ -276,7 +316,7 @@ jobs:
```yml
- name: Open issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'open-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -295,7 +335,7 @@ jobs:
```yml
- name: Remove assignees
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'remove-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -316,7 +356,7 @@ jobs:
```yml
- name: Remove labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -339,7 +379,7 @@ jobs:
```yml
- name: Set labels
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'set-labels'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -360,7 +400,7 @@ jobs:
```yml
- name: Unlock issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'unlock-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -391,7 +431,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Update comment
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -417,7 +457,7 @@ jobs:
```yml
- name: Update issue
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -464,7 +504,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: welcome
uses: actions-cool/issues-helper@v1.7
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'welcome'
token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -8,16 +8,23 @@ toc: menu
- Use two-level semantic version, such as v1, v1.1, v2, v2.1
- v1 represents the initial version
- The fixes and additions to the v1 version will be released to the v1.1 version
- When the released v1.x runs stable for a certain period of time, release the advanced v2 version
- When the released v1.x runs stable for a certain period of time or undergoes refactoring, release the advanced v2 version
- After the v2 version, the version will be released strictly according to the three-level semantics, such as v2.0.0, v2.1.0
- Version selection
- It is recommended to use the latest releases version. It can be seen in [releases](https://github.com/actions-cool/issues-helper/releases)
- You can also refer to the update log below to select the version
- The latest v1.x release code will be merged into the 1.x branch
- It also supports the direct use of branch versions. Such as:
```yml
- name: Issues Helper
uses: actions-cool/issues-helper@main
# or
- name: Issues Helper
uses: actions-cool/issues-helper@1.x
```
<embed src="../CHANGELOG.md"></embed>

View File

@@ -8,16 +8,23 @@ toc: menu
- 采用两级语义化版本如v1、v1.1、v2、v2.1
- v1 表示初始版本
- 对 v1 版本的修复和新增会发布到 v1.1 版本
- 当发布的 v1.x 运行一定时间稳定,发布进阶 v2 版本
- 当发布的 v1.x 运行一定时间稳定或进行重构时,发布进阶 v2 版本
- v2 版本后会严格按照三级语义来发布版本,如 v2.0.0、v2.1.0
- 版本选择
- 建议采用最新 releases 版本。可在 [releases](https://github.com/actions-cool/issues-helper/releases) 看到
- 同时也可参照下面的更新日志来选择版本
- 也支持直接使用分支版本。如:
- 最新的 v1.x release 代码会合并到 1.x 分支中
- 支持直接使用分支版本。如:
```yml
- name: Issues Helper
uses: actions-cool/issues-helper@main
# or
- name: Issues Helper
uses: actions-cool/issues-helper@1.x
```
<embed src="../CHANGELOG.md"></embed>

View File

@@ -22,6 +22,10 @@ Yes, you can directly modify `actions`. For example: `actions:'create-comment'`
You can view the detailed [changelog](/en-US/changelog). The latest releases version is recommended.
## What should I pay attention to when upgrading from v1.x to v2?
There is only one difference between v1.12 and v2.0.0. That is, `require-permission` in `mark-duplicate` has added the default value `write`.
## What should I do if there is no function I want here?
You can submit it in [What do you want?](https://github.com/actions-cool/issues-helper/discussions/18).

View File

@@ -22,6 +22,10 @@ GitHub Actions 是由 GitHub 免费提供的。其中 `Private` 项目每月有
你可以查看详细的 [更新日志](/changelog)。推荐采用最新 releases 版本。
## 从 v1.x 升级到 v2有什么注意的地方吗
v1.12 和 v2.0.0 版本的差别只有一处。即 `mark-duplicate` 中的 `require-permission` 增加了默认值 `write`
## 如果这里没有我想要的功能,该怎么办?
你可以在 [What do you want?](https://github.com/actions-cool/issues-helper/discussions/18) 中提出。

46
docs/guide/note.en-US.md Normal file
View File

@@ -0,0 +1,46 @@
---
toc: menu
---
<Alert type="success">
Here are some things I summarized in my use, I hope it can help you.
</Alert>
## Include judgment in `yml`
```yml
if: contains(github.event.issue.body, 'ie') == false
```
- Triggered when the issue body does not contain `ie`
- The js `includes()` syntax is not supported in the yml
- Case is not checked, `IE` and also similar to `kiekk` can also be satisfied
[More](https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#functions).
## Pass value and output in `yml`
```
with:
actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }}
count-lables: 'true'
```
- `count-lables`: Regardless of setting `true` or `'ture'`, all received in the program is in string format
At the same time, the output is also in string format
- `check-result`: The judgment condition is `if: steps.xxid.outputs.check-result =='true'`
## `GitHub Actions bot` trigger
When an action is set, such as adding a label `x1` to an issue, Actions will automatically add a label `x2` to the issue.
But if this is done by `GitHub Actions bot` (that is, the token in the actions is not passed, or the default `token: ${{ secrets.GITHUB_TOKEN }}` is used), the actions of label `x2` will not be triggered.
ref: [GitHub docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token)
## `assignees` scope
- The owner or collaborator of the warehouse, if there is an organization, including members
- Participants of the issue, including creators and commenters

47
docs/guide/note.md Normal file
View File

@@ -0,0 +1,47 @@
---
toc: menu
---
<Alert type="success">
这里记录自己在使用中总结的一些东西,希望可以帮助到你。
</Alert>
## `yml` 中包含判断
```yml
if: contains(github.event.issue.body, 'ie') == false
```
- 当 issue body 不包含 `ie` 触发
- 测试 yml 中不支持 js `includes()` 语法
- 大小写不校验,`IE` 还有同时类似 `kiekk` 也可满足
更多[查看](https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#functions)。
## `yml` 中传值和输出
```
with:
actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }}
count-lables: 'true'
```
- `count-lables`:不管设置 `true` 还是 `'ture'`,在程序里接收到的都是字符串格式
同时输出的也是字符串格式
- `check-result`:判断条件为 `if: steps.xxid.outputs.check-result == 'true'`
## `GitHub Actions bot` 触发
当设置了一个 Actions如为给一个 issue 新增 label `x1`Actions 自动为该 issue 增加 `x2` label。
但如果这个是由 `GitHub Actions bot` 完成的(即 actions 中 token 不传,或使用默认 `token: ${{ secrets.GITHUB_TOKEN }}`),则不会触发 label `x2` 的 Actions。
ref: [GitHub docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token)
## `assignees` 范围
- 仓库的所有者或协作者,若有组织,包括成员
- issue 的参与者,包括创建者、评论者

View File

@@ -33,7 +33,7 @@ jobs:
steps:
- name: help wanted
if: github.event.label.name == 'help wanted'
uses: actions-cool/issues-helper@v1.2
uses: actions-cool/issues-helper@v2.0.0
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -50,7 +50,7 @@ jobs:
- `on`: The action trigger condition
- Reference [Events that trigger workflows](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
- `uses`: Use actions name
- `uses: actions-cool/issues-helper@v1.2`。Please [refer](/en-US/changelog) to version selection
- `uses: actions-cool/issues-helper@v2.0.0`。Please [refer](/en-US/changelog) to version selection
- `issues-hepler` parameter
- `actions`: The name of the function used, **required**. Support multiple, separated by commas, such as `create-comment,close-issue` means comment and close issue
- `token`: A person who needs to have push permission token

View File

@@ -33,7 +33,7 @@ jobs:
steps:
- name: help wanted
if: github.event.label.name == 'help wanted'
uses: actions-cool/issues-helper@v1.2
uses: actions-cool/issues-helper@v2.0.0
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -50,7 +50,7 @@ jobs:
- `on`action 触发条件
- 参考 [工作流触发机制](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
- `uses`:使用 actions 名称
- `uses: actions-cool/issues-helper@v1.2`。版本选择请 [参考](/changelog)
- `uses: actions-cool/issues-helper@v2.0.0`。版本选择请 [参考](/changelog)
- `issues-hepler` 参数
- `actions`:使用功能的名称,**必填**。支持多个,需用逗号隔开,如 `create-comment,close-issue` 表示评论和关闭 issue
- `token`:需拥有 push 权限的人员 token

View File

@@ -38,7 +38,7 @@ jobs:
steps:
- name: help wanted
if: github.event.label.name == 'help wanted'
uses: actions-cool/issues-helper@v1.2
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -51,7 +51,7 @@ jobs:
## 💖 Who is using?
<embed src="../README.md#L996-L1024"></embed>
<embed src="../README.md#RE-/<table>[^]+?[\r\n]<\/table>/"></embed>
## ⚡ Feedback

View File

@@ -38,7 +38,7 @@ jobs:
steps:
- name: help wanted
if: github.event.label.name == 'help wanted'
uses: actions-cool/issues-helper@v1.2
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
@@ -51,7 +51,7 @@ jobs:
## 💖 谁在使用?
<embed src="../README.md#L996-L1024"></embed>
<embed src="../README.md#RE-/<table>[^]+?[\r\n]<\/table>/"></embed>
## ⚡ 反馈

View File

@@ -1,6 +1,6 @@
{
"name": "issue-helper",
"version": "1.7.0",
"name": "issues-helper",
"version": "2.1.1",
"private": true,
"description": "Some operations on issue.",
"main": "src/main.js",
@@ -10,15 +10,18 @@
"docs-dev:build": "UMI_ENV=dev dumi build",
"docs:deploy": "gh-pages -d docs-dist",
"deploy": "npm run docs:build && npm run docs:deploy",
"format": "prettier --write **/*.ts **/*.js",
"format-check": "prettier --check **/*.ts **/*.js",
"package": "ncc build src/main.js -o dist",
"update": "node ./script/update-user.js",
"main": "node ./src/main.js"
"users": "node ./script/update-users.js",
"main": "node ./src/main.js",
"ver": "node ./script/update-version.js"
},
"author": "xrkffgg",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/actions-cool/issue-helper.git",
"url": "https://github.com/actions-cool/issues-helper.git",
"branch": "main"
},
"keywords": [
@@ -31,13 +34,15 @@
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@octokit/rest": "^18.0.12",
"dayjs": "^1.9.7"
"dayjs": "^1.9.7",
"lodash": "^4.17.20"
},
"devDependencies": {
"@umijs/fabric": "^2.5.6",
"@vercel/ncc": "^0.25.1",
"common-tags": "^1.8.0",
"dotenv": "^8.2.0",
"dumi": "^1.1.0",
"dumi": "^1.1.1",
"gh-pages": "^3.1.0",
"react": "^17.0.1"
}

BIN
public/month.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -1,111 +0,0 @@
const { readFileSync, writeFileSync } = require('fs');
const { format } = require('prettier');
const { stripIndent } = require('common-tags');
// **************************************************************************
let users = [
{
url: 'https://github.com/ant-design/ant-design',
logo: 'https://avatars1.githubusercontent.com/u/12101536?s=200&v=4'
},
{
url: 'https://github.com/vueComponent/ant-design-vue',
logo: 'https://avatars1.githubusercontent.com/u/32120805?s=200&v=4'
},
{
url: 'https://github.com/umijs/dumi',
logo: 'https://avatars1.githubusercontent.com/u/33895495?s=200&v=4'
},
{
url: 'https://github.com/umijs/umi',
logo: 'https://avatars1.githubusercontent.com/u/33895495?s=200&v=4'
},
{
url: 'https://github.com/AttoJS/vue-request',
logo: 'https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png'
},
{
url: 'https://github.com/mui-org/material-ui',
logo: 'https://avatars2.githubusercontent.com/u/33663932?s=200&v=4'
},
];
users.sort((a, b) => getName(a).localeCompare(getName(b)));
// **************************************************************************
let table = '';
let row = users.length / 5;
let lastNo = users.length % 5;
if (lastNo != 0) row += 1;
for (let j = 1; j <= row; j++) {
let data = '';
data = stripIndent`
<tr>
<td align="center">${getImg(users[(j-1)*5])}</td>
<td align="center">${getImg(users[(j-1)*5+1])}</td>
<td align="center">${getImg(users[(j-1)*5+2])}</td>
<td align="center">${getImg(users[(j-1)*5+3])}</td>
<td align="center">${getImg(users[(j-1)*5+4])}</td>
</tr>
<tr>
<td width="160" align="center">${getName(users[(j-1)*5])}</td>
<td width="160" align="center">${getName(users[(j-1)*5+1])}</td>
<td width="160" align="center">${getName(users[(j-1)*5+2])}</td>
<td width="160" align="center">${getName(users[(j-1)*5+3])}</td>
<td width="160" align="center">${getName(users[(j-1)*5+4])}</td>
</tr>
`;
table += data
};
table = `<table>
${table}
</table>
`;
// **************************************************************************
const point = '<table>';
const last = `
## LICENSE
[MIT](https://github.com/actions-cool/issues-helper/blob/main/LICENSE)
`;
// **************************************************************************
const cn = readFileSync('./README.md', 'utf8');
const cnIn = cn.indexOf(point);
const cnBefore = cn.substring(0, cnIn);
const newcn = cnBefore + table + last;
writeFileSync('./README.md', newcn);
console.log(`🎉 Done cn`);
// **************************************************************************
const en = readFileSync('./README.en-US.md', 'utf8');
const enIn = en.indexOf(point);
const enBefore = en.substring(0, enIn);
const newen = enBefore + table + last;
writeFileSync('./README.en-US.md', newen);
console.log(`🎉 Done en`);
// **************************************************************************
function getImg (o) {
if (o) {
return `<a href="${o.url}"><img src="${o.logo}" width="46" /></a>`
}
return ``
};
function getName (o) {
if (o) {
return o.url.split('/').slice(-1)[0]
}
return ``
};
// **************************************************************************

82
script/update-users.js Normal file
View File

@@ -0,0 +1,82 @@
const { readFileSync, writeFileSync } = require('fs');
const { stripIndent } = require('common-tags');
// **************************************************************************
let { users } = require('../USERS.js');
users.sort((a, b) => getName(a).localeCompare(getName(b)));
// **************************************************************************
let table = '';
let row = users.length / 4;
let lastNo = users.length % 4;
if (lastNo != 0) row += 1;
for (let j = 1; j <= row; j++) {
let data = '';
data = stripIndent`
<tr>
<td align="center" width="180">${getImg(users[(j - 1) * 4])}</td>
<td align="center" width="180">${getImg(users[(j - 1) * 4 + 1])}</td>
<td align="center" width="180">${getImg(users[(j - 1) * 4 + 2])}</td>
<td align="center" width="180">${getImg(users[(j - 1) * 4 + 3])}</td>
</tr>`;
table += data;
}
table = `<table>
${table}
</table>
`;
// **************************************************************************
const point = '<table>';
const cnPoint = `## 列 表`;
const enPoint = `## List`;
// **************************************************************************
const cn = readFileSync('./README.md', 'utf8');
const cnIn = cn.indexOf(point);
const cnAfterIn = cn.indexOf(cnPoint);
const cnBefore = cn.substring(0, cnIn);
const cnAfter = cn.substring(cnAfterIn, cn.length);
const newcn = cnBefore + table + cnAfter;
writeFileSync('./README.md', newcn);
console.log(`🎉 Done cn`);
// **************************************************************************
const en = readFileSync('./README.en-US.md', 'utf8');
const enIn = en.indexOf(point);
const enAfterIn = en.indexOf(enPoint);
const enBefore = en.substring(0, enIn);
const enAfter = en.substring(enAfterIn, en.length);
const newen = enBefore + table + enAfter;
writeFileSync('./README.en-US.md', newen);
console.log(`🎉 Done en`);
// **************************************************************************
function getImg(o) {
if (o) {
return `
<a href="${o.url}">
<img src="${o.logo}" width="46" />
<div>${getName(o)}</div>
</a>`;
}
return ``;
}
function getName(o) {
if (o) {
return o.url.split('/').slice(-1)[0];
}
return ``;
}
// **************************************************************************

44
script/update-version.js Normal file
View File

@@ -0,0 +1,44 @@
const { readFileSync, writeFileSync } = require('fs');
const last = /v2\.1\.1/g;
const now = 'v2.2.0';
let readme = readFileSync('./README.md', 'utf-8');
readme = readme.replace(last, now);
writeFileSync('./README.md', readme);
console.log('readme done!');
let readmeen = readFileSync('./README.en-US.md', 'utf-8');
readmeen = readmeen.replace(last, now);
writeFileSync('./README.en-US.md', readmeen);
console.log('readmeen done!');
let index = readFileSync('./docs/index.md', 'utf-8');
index = index.replace(last, now);
writeFileSync('./docs/index.md', index);
console.log('index done!');
let indexen = readFileSync('./docs/index.en-US.md', 'utf-8');
indexen = indexen.replace(last, now);
writeFileSync('./docs/index.en-US.md', indexen);
console.log('indexen done!');
let base = readFileSync('./docs/base.md', 'utf-8');
base = base.replace(last, now);
writeFileSync('./docs/base.md', base);
console.log('base done!');
let baseen = readFileSync('./docs/base.en-US.md', 'utf-8');
baseen = baseen.replace(last, now);
writeFileSync('./docs/base.en-US.md', baseen);
console.log('baseen done!');
let adv = readFileSync('./docs/advanced.md', 'utf-8');
adv = adv.replace(last, now);
writeFileSync('./docs/advanced.md', adv);
console.log('adv done!');
let adven = readFileSync('./docs/advanced.en-US.md', 'utf-8');
adven = adven.replace(last, now);
writeFileSync('./docs/advanced.en-US.md', adven);
console.log('adven done!');

298
src/advanced.js Normal file
View File

@@ -0,0 +1,298 @@
require('dotenv').config();
const core = require('@actions/core');
const { Octokit } = require('@octokit/rest');
const {
doAddLabels,
doCreateComment,
doCloseIssue,
doLockIssue,
doCreateIssue,
} = require('./base.js');
const { doQueryIssues, getIssuesInMonth, getCreatedMonth } = require('./public.js');
const { dealStringToArr, matchKeyword, getPreMonth } = require('./util.js');
// **************************************************************************
var dayjs = require('dayjs');
var utc = require('dayjs/plugin/utc');
dayjs.extend(utc);
// **************************************************************************
const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
let direction = core.getInput('direction');
direction = direction === 'desc' ? 'desc' : 'asc';
const commentAuth = core.getInput('comment-auth');
const bodyIncludes = core.getInput('body-includes');
const titleIncludes = core.getInput('title-includes');
const assigneeIncludes = core.getInput('assignee-includes');
let issueState = core.getInput('issue-state') || 'open';
if (issueState != 'all' && issueState != 'closed') {
issueState = 'open';
}
const inactiveLabel = core.getInput('inactive-label') || 'inactive';
// **************************************************************************
async function doCheckInactive(owner, repo, labels) {
const issues = await doQueryIssues(owner, repo, labels, issueState);
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
let arr = [];
issues[i].labels.forEach(it => {
arr.push(it.name);
});
if (!arr.includes(inactiveLabel)) {
await doAddLabels(owner, repo, issues[i].number, inactiveLabel);
if (core.getInput('body')) {
await doCreateComment(owner, repo, issues[i].number, core.getInput('body'));
}
} else {
core.info(`Actions: [add-inactive] issue ${issues[i].number} has label!`);
}
}
} else {
core.info(`Actions: [query-issues] empty!`);
}
}
/**
* 检查 issue 是否满足条件,满足返回 true
* 当前 issue 的指定人是否有一个满足 assigneeIncludes 里的某个
* 关键字匹配,是否包含前一个某个+后一个某个 '官网,网站/挂了,无法访问'
*/
async function doCheckIssue(owner, repo, issueNumber) {
var checkResult = true;
const issue = await octokit.issues.get({
owner,
repo,
issue_number: issueNumber,
});
if (!!checkResult && assigneeIncludes) {
let assigneesCheck = dealStringToArr(assigneeIncludes);
let checkAssignee = false;
issue.data.assignees.forEach(it => {
if (checkResult && !checkAssignee && assigneesCheck.includes(it.login)) {
checkResult = true;
checkAssignee = true;
}
});
!checkAssignee ? (checkResult = false) : null;
}
if (!!checkResult && titleIncludes) {
const titleArr = titleIncludes.split('/');
const keyword1 = dealStringToArr(titleArr[0]);
const keyword2 = dealStringToArr(titleArr[1]);
checkResult = keyword2.length
? matchKeyword(issue.data.title, keyword1) && matchKeyword(issue.data.title, keyword2)
: matchKeyword(issue.data.title, keyword1);
}
if (!!checkResult && bodyIncludes) {
const bodyArr = bodyIncludes.split('/');
const keyword1 = dealStringToArr(bodyArr[0]);
const keyword2 = dealStringToArr(bodyArr[1]);
checkResult = keyword2.length
? matchKeyword(issue.data.body, keyword1) && matchKeyword(issue.data.body, keyword2)
: matchKeyword(issue.data.body, keyword1);
}
core.info(`Actions: [check-issue][${!!checkResult}] success!`);
core.setOutput('check-result', !!checkResult);
}
async function doCloseIssues(owner, repo, labels) {
const issues = await doQueryIssues(owner, repo, labels, 'open');
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
await doCloseIssue(owner, repo, issues[i].number);
if (core.getInput('body')) {
await doCreateComment(owner, repo, issues[i].number, core.getInput('body'));
}
}
} else {
core.info(`Actions: [query-issues] empty!`);
}
}
async function doFindComments(owner, repo, issueNumber) {
const res = await octokit.issues.listComments({
owner,
repo,
issue_number: issueNumber,
});
core.info(`Actions: [find-comments][${issueNumber}] success!`);
let comments = [];
res.data.forEach(item => {
const a = commentAuth ? item.user.login === commentAuth : true;
const b = bodyIncludes ? item.body.includes(bodyIncludes) : true;
if (a && b) {
comments.push({
id: item.id,
auth: item.user.login,
body: item.body,
created: item.created_at,
updated: item.updated_at,
});
if (direction === 'desc') {
comments.reverse();
}
}
});
core.setOutput('comments', comments);
}
async function doLockIssues(owner, repo, labels) {
const issues = await doQueryIssues(owner, repo, labels, issueState);
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
await doLockIssue(owner, repo, issues[i].number);
if (core.getInput('body')) {
await doCreateComment(owner, repo, issues[i].number, core.getInput('body'));
}
}
} else {
core.info(`Actions: [query-issues] empty!`);
}
}
async function doMonthStatistics(owner, repo, labels, assignees) {
const countLables = core.getInput('count-lables');
const countComments = core.getInput('count-comments');
const thisMonth = dayjs.utc().month() + 1;
const year = thisMonth == 1 ? dayjs.utc().year() - 1 : dayjs.utc().year();
const month = getPreMonth(thisMonth);
const showMonth = month < 10 ? `0${month}` : month;
let issues = await getIssuesInMonth(owner, repo, thisMonth);
if (issues.length == 0) {
core.info(`Actions: [query-issues-${month}] empty!`);
return false;
}
issues = issues.filter(i => {
return getCreatedMonth(i.created_at) == month;
});
let total = issues.length;
let totalIssues = [...issues];
let openTotal = 0;
let openIssuesNumber = [];
let closeTotal = 0;
let closeIssuesNumber = [];
let labelsTotals = [];
const title = `[${owner}/${repo}] Month Statistics: ${year}-${showMonth}`;
for (let i = 0; i < issues.length; i++) {
if (issues[i].state == 'closed') {
closeTotal += 1;
closeIssuesNumber.push(issues[i].number);
} else if (issues[i].state == 'open') {
openTotal += 1;
openIssuesNumber.push(issues[i].number);
}
if (countLables && issues[i].labels) {
issues[i].labels.forEach(l => {
if (l.name in labelsTotals) {
labelsTotals[l.name] += 1;
} else {
labelsTotals[l.name] = 1;
}
});
}
}
let now = dayjs()
.utc()
.format('YYYY-MM-DD HH:mm:ss');
let body = `
- Created time: ${now}
- Time base: UTC +0
`;
let totalShow = `
### Count
| Total | Open | Closed |
| -- | -- | -- |
| ${total} | ${openTotal} | ${closeTotal} |
`;
body += totalShow;
if (countLables == 'true') {
let labelsArr = [];
for (var lab in labelsTotals) {
labelsArr.push({
labelName: lab,
number: labelsTotals[lab],
});
}
labelsArr.sort((a, b) => b.number - a.number);
let labelsTitle = `
### Labels statistics
<table>
<tr>
<th>Name</th>
<th>Number</th>
</tr>`;
let labelsBody = '';
labelsArr.forEach(it => {
labelsBody += `<tr><td>${it.labelName}</td><td>${it.number}</td></tr>`;
});
body =
body +
labelsTitle +
labelsBody +
`</table>
`;
}
if (countComments == 'true') {
totalIssues.sort((a, b) => b.comments - a.comments);
const maxComments = totalIssues.slice(0, 3);
let commentTitle = `
### Most comments
<table>
<tr>
<th>#</th>
<th>Issue</th>
<th>Title</th>
<th>Number</th>
<th>State</th>
</tr>
`;
let commentBody = '';
maxComments.forEach((it, ind) => {
commentBody += `<tr>
<td>${ind + 1}</td>
<td>${it.number}</td>
<td>${it.title}</td>
<td>${it.comments}</td>
<td>${it.state}</td></tr>`;
});
body = body + commentTitle + commentBody + '</table>';
}
await doCreateIssue(owner, repo, title, body, labels, assignees);
}
// **************************************************************************
module.exports = {
doCheckInactive,
doCheckIssue,
doCloseIssues,
doFindComments,
doLockIssues,
doMonthStatistics,
};

4
src/app.jsx Normal file
View File

@@ -0,0 +1,4 @@
// Just for dumi style
import './less/main.less';
import './less/markdown.less';
import './less/dumi.less';

493
src/base.js Normal file
View File

@@ -0,0 +1,493 @@
require('dotenv').config();
const core = require('@actions/core');
const github = require('@actions/github');
const { Octokit } = require('@octokit/rest');
// **************************************************************************
const ALLREACTIONS = ['+1', '-1', 'laugh', 'confused', 'heart', 'hooray', 'rocket', 'eyes'];
const { doQueryIssues } = require('./public.js');
const {
dealStringToArr,
dealRandomAssignees,
testDuplicate,
checkPermission,
} = require('./util.js');
// **************************************************************************
const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
const context = github.context;
const contents = core.getInput('contents');
const randomTo = core.getInput('random-to');
// **************************************************************************
async function doAddAssignees(owner, repo, issueNumber, assignees) {
const arr = dealRandomAssignees(assignees, randomTo);
await octokit.issues.addAssignees({
owner,
repo,
issue_number: issueNumber,
assignees: arr,
});
core.info(`Actions: [add-assignees][${arr}] success!`);
}
async function doAddLabels(owner, repo, issueNumber, labels) {
await octokit.issues.addLabels({
owner,
repo,
issue_number: issueNumber,
labels: dealStringToArr(labels),
});
core.info(`Actions: [add-labels][${labels}] success!`);
}
async function doCloseIssue(owner, repo, issueNumber) {
await octokit.issues.update({
owner,
repo,
issue_number: issueNumber,
state: 'closed',
});
core.info(`Actions: [close-issue][${issueNumber}] success!`);
}
async function doCreateComment(owner, repo, issueNumber, body) {
const { data } = await octokit.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body,
});
core.info(`Actions: [create-comment][${body}] success!`);
core.setOutput('comment-id', data.id);
if (contents) {
await doCreateCommentContent(owner, repo, data.id, dealStringToArr(contents));
}
}
async function doCreateCommentContent(owner, repo, commentId, contents) {
if (contents.length) {
contents.forEach(async item => {
if (testContent(item)) {
await octokit.reactions.createForIssueComment({
owner,
repo,
comment_id: commentId,
content: item,
});
core.info(`Actions: [create-reactions][${item}] success!`);
}
});
}
}
async function doCreateIssue(owner, repo, title, body, labels, assignees) {
let params = {
owner,
repo,
title,
body,
labels: dealStringToArr(labels),
assignees: dealRandomAssignees(assignees, randomTo),
};
const { data } = await octokit.issues.create(params);
core.info(`Actions: [create-issue][${title}] success!`);
core.setOutput('issue-number', data.number);
if (contents) {
await doCreateIssueContent(owner, repo, data.number, dealStringToArr(contents));
}
}
async function doCreateIssueContent(owner, repo, issueNumber, contents) {
if (contents.length) {
contents.forEach(async item => {
if (testContent(item)) {
await octokit.reactions.createForIssue({
owner,
repo,
issue_number: issueNumber,
content: item,
});
core.info(`Actions: [create-reactions][${item}] success!`);
}
});
}
}
async function doCreateLabel(owner, repo) {
const name = core.getInput('label-name');
const color = core.getInput('label-color') || 'ededed';
const description = core.getInput('label-desc') || '';
if (!name) {
core.setFailed(`This actions should input 'label-name'!`);
return false;
}
try {
await octokit.issues.createLabel({
owner,
repo,
name,
color,
description,
});
core.info(`Actions: [create-label][${name}] success!`);
} catch (err) {
console.log(err.message);
}
}
async function doDeleteComment(owner, repo, commentId) {
await octokit.issues.deleteComment({
owner,
repo,
comment_id: commentId,
});
core.info(`Actions: [delete-comment][${commentId}] success!`);
}
async function doLockIssue(owner, repo, issueNumber) {
const lockReason = core.getInput('lock-reason');
let params = {
owner,
repo,
issue_number: issueNumber,
};
const reasons = ['off-topic', 'too heated', 'resolved', 'spam'];
if (lockReason && reasons.includes(lockReason)) {
params.lock_reason = lockReason;
}
await octokit.issues.lock(params);
core.info(`Actions: [lock-issue][${issueNumber}] success!`);
}
async function doMarkDuplicate(owner, repo, labels) {
if (context.eventName != 'issue_comment') {
core.info(`This actions only support on 'issue_comment'!`);
return false;
}
if (context.payload.action == 'created' || context.payload.action == 'edited') {
const duplicateCommand = core.getInput('duplicate-command');
const duplicateLabels = core.getInput('duplicate-labels');
const removeLables = core.getInput('remove-labels');
const closeIssue = core.getInput('close-issue');
const requirePermission = core.getInput('require-permission') || 'write';
const commentId = context.payload.comment.id;
const commentBody = context.payload.comment.body;
const commentUser = context.payload.comment.user.login;
const issueNumber = context.payload.issue.number;
const ifCommandInput = !!duplicateCommand;
if (
!commentBody.includes('?') &&
((ifCommandInput &&
commentBody.startsWith(duplicateCommand) &&
commentBody.split(' ')[0] == duplicateCommand) ||
testDuplicate(commentBody))
) {
try {
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
if (ifCommandInput) {
const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of');
await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);
} else if (contents) {
await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents));
}
const issue = await octokit.issues.get({
owner,
repo,
issue_number: issueNumber,
});
let newLabels = [];
if (issue.data.labels.length > 0) {
newLabels = issue.data.labels
.map(({ name }) => name)
.filter(name => !dealStringToArr(removeLables).includes(name));
}
if (duplicateLabels) {
newLabels = [...newLabels, ...dealStringToArr(duplicateLabels)];
}
if (labels) {
newLabels = dealStringToArr(labels);
}
if (newLabels.length > 0) {
await doSetLabels(owner, repo, issueNumber, newLabels.toString());
core.info(`Actions: [mark-duplicate-labels][${newLabels}] success!`);
}
if (closeIssue == 'true') {
await doCloseIssue(owner, repo, issueNumber);
}
} catch (error) {
core.info(error.message);
}
} else {
core.info(
`This comment body should start whith 'duplicate-command' or 'Duplicate of' and not include '?'`,
);
}
} else {
core.info(`This actions only support on 'issue_comment' created or edited!`);
}
}
async function doOpenIssue(owner, repo, issueNumber) {
await octokit.issues.update({
owner,
repo,
issue_number: issueNumber,
state: 'open',
});
core.info(`Actions: [open-issue][${issueNumber}] success!`);
}
async function doRemoveAssignees(owner, repo, issueNumber, assignees) {
await octokit.issues.removeAssignees({
owner,
repo,
issue_number: issueNumber,
assignees: dealStringToArr(assignees),
});
core.info(`Actions: [remove-assignees][${assignees}] success!`);
}
async function doRemoveLabels(owner, repo, issueNumber, labels) {
const dealLabels = dealStringToArr(labels);
for (label of dealLabels) {
await octokit.issues.removeLabel({
owner,
repo,
issue_number: issueNumber,
name: label,
});
core.info(`Actions: [remove-labels-foreach][${label}] success!`);
}
core.info(`Actions: [remove-labels][${labels}] success!`);
}
async function doSetLabels(owner, repo, issueNumber, labels) {
// 概率性出现问题https://github.com/octokit/rest.js/issues/1982规避 setLabels
if (labels) {
// await octokit.issues.setLabels({
// owner,
// repo,
// issue_number: issueNumber,
// labels: dealStringToArr(labels)
// });
const issue = await octokit.issues.get({
owner,
repo,
issue_number: issueNumber,
});
const baseLabels = issue.data.labels.map(({ name }) => name);
const removeLabels = baseLabels.filter(name => !dealStringToArr(labels).includes(name));
const addLabels = dealStringToArr(labels).filter(name => !baseLabels.includes(name));
if (removeLabels.length > 0) {
await doRemoveLabels(owner, repo, issueNumber, removeLabels.toString());
core.info(`Actions: [set-labels-remove][${removeLabels}] success!`);
}
if (addLabels.length > 0) {
await doAddLabels(owner, repo, issueNumber, addLabels.toString());
core.info(`Actions: [set-labels-add][${addLabels}] success!`);
}
core.info(`Actions: [set-labels][${labels}] success!`);
}
}
async function doUnlockIssue(owner, repo, issueNumber) {
await octokit.issues.unlock({
owner,
repo,
issue_number: issueNumber,
});
core.info(`Actions: [unlock-issue][${issueNumber}] success!`);
}
async function doUpdateComment(owner, repo, commentId, body, updateMode, ifUpdateBody) {
const comment = await octokit.issues.getComment({
owner,
repo,
comment_id: commentId,
});
const comment_body = comment.data.body;
let params = {
owner,
repo,
comment_id: commentId,
};
if (core.getInput('body') || ifUpdateBody) {
if (updateMode === 'append') {
params.body = `${comment_body}\n${body}`;
} else {
params.body = body;
}
await octokit.issues.updateComment(params);
core.info(`Actions: [update-comment][${commentId}] success!`);
}
if (contents) {
await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents));
}
}
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;
let issue_labels = [];
if (issue.data.labels.length > 0) {
issue.data.labels.forEach(it => {
issue_labels.push(it.name);
});
}
let issue_assignees = [];
if (issue.data.assignees.length > 0) {
issue.data.assignees.forEach(it => {
issue_assignees.push(it.login);
});
}
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;
params.labels = labels ? dealStringToArr(labels) : issue_labels;
params.assignees = assignees ? dealStringToArr(assignees) : issue_assignees;
await octokit.issues.update(params);
core.info(`Actions: [update-issue][${issueNumber}] success!`);
if (contents) {
await doCreateIssueContent(owner, repo, issueNumber, contents);
}
}
async function doWelcome(owner, repo, assignees, labels, body) {
const context = github.context;
const isIssue = !!context.payload.issue;
const issueContents = core.getInput('issue-contents');
if (!isIssue) {
core.setFailed('The event that triggered this action must be a issue. Error!');
} else {
const auth = context.payload.sender.login;
core.info(`Actions: [welcome: auth=][${auth}]`);
const issueNumber = context.issue.number;
const issues = await doQueryIssues(owner, repo, false, 'all', auth);
if (issues.length == 0 || (issues.length == 1 && issues[0].number == issueNumber)) {
if (core.getInput('body')) {
await doCreateComment(owner, repo, issueNumber, body);
} else {
core.info(`Actions: [welcome] no body!`);
}
if (assignees) {
await doAddAssignees(owner, repo, issueNumber, assignees);
}
if (labels) {
await doAddLabels(owner, repo, issueNumber, labels);
}
if (issueContents) {
await doCreateIssueContent(owner, repo, issueNumber, dealStringToArr(issueContents));
}
} else {
core.info(`Actions: [welcome][${auth}] is not first time!`);
}
}
}
// **************************************************************************
function testContent(con) {
if (ALLREACTIONS.includes(con)) {
return true;
} else {
core.setFailed('This actions not supported!');
return false;
}
}
// **************************************************************************
module.exports = {
doAddAssignees,
doAddLabels,
doCloseIssue,
doCreateComment,
doCreateCommentContent,
doCreateIssue,
doCreateIssueContent,
doCreateLabel,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
doOpenIssue,
doRemoveAssignees,
doRemoveLabels,
doSetLabels,
doUnlockIssue,
doUpdateComment,
doUpdateIssue,
doWelcome,
};

787
src/do.js
View File

@@ -1,787 +0,0 @@
require('dotenv').config();
const core = require("@actions/core");
const github = require("@actions/github");
const { Octokit } = require('@octokit/rest');
var dayjs = require('dayjs');
var utc = require('dayjs/plugin/utc');
dayjs.extend(utc);
var isSameOrBefore = require('dayjs/plugin/isSameOrBefore');
dayjs.extend(isSameOrBefore);
const ALLREACTIONS = [
"+1",
"-1",
"laugh",
"confused",
"heart",
"hooray",
"rocket",
"eyes",
];
const {
dealInput,
matchKeyword,
testDuplicate,
getPreMonth
} = require('./util.js');
const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
const contents = core.getInput("contents");
const issueContents = core.getInput("issue-contents");
// advanced
let direction = core.getInput("direction");
direction = direction === 'desc' ? 'desc' : 'asc';
const commentAuth = core.getInput("comment-auth");
const bodyIncludes = core.getInput('body-includes');
const titleIncludes = core.getInput('title-includes');
const assigneeIncludes = core.getInput('assignee-includes');
const issueCreator = core.getInput("issue-creator");
const issueAssignee = core.getInput('issue-assignee');
const issueMentioned = core.getInput('issue-mentioned');
let issueState = core.getInput("issue-state") || 'open';
if (issueState != 'all' && issueState != 'closed') {
issueState = 'open';
}
const inactiveDay = core.getInput("inactive-day");
const inactiveLabel = core.getInput("inactive-label") || 'inactive';
const perPage = 100;
// context
const context = github.context;
// base
async function doAddAssignees (owner, repo, issueNumber, assignees) {
await octokit.issues.addAssignees({
owner,
repo,
issue_number: issueNumber,
assignees: dealInput(assignees)
});
core.info(`Actions: [add-assignees][${assignees}] success!`);
};
async function doAddLabels (owner, repo, issueNumber, labels) {
await octokit.issues.addLabels({
owner,
repo,
issue_number: issueNumber,
labels: dealInput(labels)
});
core.info(`Actions: [add-labels][${labels}] success!`);
};
async function doCloseIssue (owner, repo, issueNumber) {
await octokit.issues.update({
owner,
repo,
issue_number: issueNumber,
state: 'closed'
});
core.info(`Actions: [close-issue][${issueNumber}] success!`);
};
async function doCreateComment (owner, repo, issueNumber, body) {
const { data } = await octokit.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body
});
core.info(`Actions: [create-comment][${body}] success!`);
core.setOutput("comment-id", data.id);
if (contents) {
await doCreateCommentContent(owner, repo, data.id, dealInput(contents));
}
};
async function doCreateCommentContent(owner, repo, commentId, contents) {
if (contents.length) {
contents.forEach(async item => {
if (testContent(item)) {
await octokit.reactions.createForIssueComment({
owner,
repo,
comment_id: commentId,
content: item
});
core.info(`Actions: [create-reactions][${item}] success!`);
}
})
}
};
async function doCreateIssue (owner, repo, title, body, labels, assignees) {
let params = {
owner,
repo,
title,
body,
labels: dealInput(labels),
assignees: dealInput(assignees),
};
const { data } = await octokit.issues.create(params);
core.info(`Actions: [create-issue][${title}] success!`);
core.setOutput("issue-number", data.number);
if (contents) {
await doCreateIssueContent(owner, repo, data.number, dealInput(contents));
}
};
async function doCreateIssueContent(owner, repo, issueNumber, contents) {
if (contents.length) {
contents.forEach(async item => {
if (testContent(item)) {
await octokit.reactions.createForIssue({
owner,
repo,
issue_number: issueNumber,
content: item
});
core.info(`Actions: [create-reactions][${item}] success!`);
}
})
}
};
async function doDeleteComment (owner, repo, commentId) {
await octokit.issues.deleteComment({
owner,
repo,
comment_id: commentId
});
core.info(`Actions: [delete-comment][${commentId}] success!`);
};
async function doLockIssue (owner, repo, issueNumber) {
await octokit.issues.lock({
owner,
repo,
issue_number: issueNumber,
});
core.info(`Actions: [lock-issue][${issueNumber}] success!`);
};
async function doMarkDuplicate (owner, repo, labels) {
if (context.eventName != 'issue_comment') {
core.info(`This actions only support on 'issue_comment'!`);
return false;
}
if (context.payload.action != 'created') {
core.info(`This actions only support on 'issue_comment' created!`);
return false;
}
const duplicateCommand = core.getInput("duplicate-command");
const duplicateLabels = core.getInput("duplicate-labels");
const closeIssue = core.getInput("close-issue");
const commentId = context.payload.comment.id;
const commentBody = context.payload.comment.body;
const issueNumber = context.payload.issue.number;
const ifCommandInput = !!duplicateCommand;
if ((ifCommandInput && commentBody.startsWith(duplicateCommand) && commentBody.split(' ')[0] == duplicateCommand) || testDuplicate(commentBody)) {
if (ifCommandInput) {
const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of');
await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);
} else if (contents) {
await doCreateCommentContent(owner, repo, commentId, dealInput(contents));
}
if (duplicateLabels) {
await doAddLabels(owner, repo, issueNumber, duplicateLabels);
}
if (labels) {
await doSetLabels(owner, repo, issueNumber, labels);
}
if (closeIssue == 'true') {
await doCloseIssue(owner, repo, issueNumber);
}
} else {
core.info(`This comment body should start whith 'duplicate-command'`);
}
};
async function doOpenIssue (owner, repo, issueNumber) {
await octokit.issues.update({
owner,
repo,
issue_number: issueNumber,
state: 'open'
});
core.info(`Actions: [open-issue][${issueNumber}] success!`);
};
async function doRemoveAssignees (owner, repo, issueNumber, assignees) {
await octokit.issues.removeAssignees({
owner,
repo,
issue_number: issueNumber,
assignees: dealInput(assignees),
});
core.info(`Actions: [remove-assignees][${assignees}] success!`);
};
async function doRemoveLabels (owner, repo, issueNumber, labels) {
const issue = await octokit.issues.get({
owner,
repo,
issue_number: issueNumber
});
const dealLabels = dealInput(labels);
let addLables = [];
if (dealLabels.length) {
issue.data.labels.forEach(item => {
!dealLabels.includes(item.name) ? addLables.push(item.name) : '';
})
await octokit.issues.setLabels({
owner,
repo,
issue_number: issueNumber,
labels: addLables
});
core.info(`Actions: [remove-labels][${labels}] success!`);
}
};
async function doSetLabels (owner, repo, issueNumber, labels) {
await octokit.issues.setLabels({
owner,
repo,
issue_number: issueNumber,
labels: dealInput(labels)
});
core.info(`Actions: [set-labels][${labels}] success!`);
};
async function doUnlockIssue (owner, repo, issueNumber) {
await octokit.issues.unlock({
owner,
repo,
issue_number: issueNumber,
});
core.info(`Actions: [unlock-issue][${issueNumber}] success!`);
};
async function doUpdateComment (
owner,
repo,
commentId,
body,
updateMode,
ifUpdateBody,
) {
const comment = await octokit.issues.getComment({
owner,
repo,
comment_id: commentId
})
const comment_body = comment.data.body;
let params = {
owner,
repo,
comment_id: commentId
};
if (core.getInput("body") || ifUpdateBody) {
if (updateMode === 'append') {
params.body = `${comment_body}\n${body}`;
} else {
params.body = body;
}
await octokit.issues.updateComment(params);
core.info(`Actions: [update-comment][${commentId}] success!`);
}
if (contents) {
await doCreateCommentContent(owner, repo, commentId, dealInput(contents));
}
};
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;
let issue_labels = [];
if (issue.data.labels.length > 0) {
issue.data.labels.forEach(it =>{
issue_labels.push(it.name);
});
}
let issue_assignees = [];
if (issue.data.assignees.length > 0) {
issue.data.assignees.forEach(it =>{
issue_assignees.push(it.login);
});
}
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;
params.labels = labels ? dealInput(labels) : issue_labels;
params.assignees = assignees ? dealInput(assignees) : issue_assignees;
await octokit.issues.update(params);
core.info(`Actions: [update-issue][${issueNumber}] success!`);
if (contents) {
await doCreateIssueContent(owner, repo, issueNumber, contents);
}
};
async function doWelcome (owner, repo, assignees, labels, body) {
const context = github.context;
const isIssue = !!context.payload.issue;
if (!isIssue) {
core.setFailed("The event that triggered this action must be a issue. Error!");
} else {
const auth = context.payload.sender.login;
core.info(`Actions: [welcome: auth=][${auth}]`);
const issueNumber = context.issue.number;
const issues = await doQueryIssues(owner, repo, false, 'all', auth);
if (issues.length == 0 || (issues.length == 1 && issues[0].number == issueNumber)) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, body);
} else {
core.info(`Actions: [welcome] no body!`);
}
if (assignees) {
await doAddAssignees(owner, repo, issueNumber, assignees);
}
if (labels) {
await doAddLabels(owner, repo, issueNumber, labels);
}
if (issueContents) {
await doCreateIssueContent(owner, repo, issueNumber, dealInput(issueContents));
}
} else {
core.info(`Actions: [welcome][${auth}] is not first time!`);
}
}
};
// advanced
async function doCheckInactive (owner, repo, labels) {
const issues = await doQueryIssues(owner, repo, labels, issueState);
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
if (!JSON.stringify(issues[i].labels).includes(inactiveLabel)) {
await doAddLabels(owner, repo, issues[i].number, inactiveLabel);
if (core.getInput("body")) {
await doCreateComment(owner, repo, issues[i].number, core.getInput("body"));
}
} else {
core.info(`Actions: [add-inactive] issue ${issues[i].number} has label!`);
}
}
} else {
core.info(`Actions: [query-issues] empty!`);
}
};
/**
* 检查 issue 是否满足条件,满足返回 true
* 当前 issue 的指定人是否有一个满足 assigneeIncludes 里的某个
* 关键字匹配,是否包含前一个某个+后一个某个 '官网,网站/挂了,无法访问'
*/
async function doCheckIssue (owner, repo, issueNumber) {
var checkResult = true;
const issue = await octokit.issues.get({
owner,
repo,
issue_number: issueNumber
});
if (!!checkResult && assigneeIncludes) {
let assigneesCheck = dealInput(assigneeIncludes);
let checkAssignee = false;
issue.data.assignees.forEach(it => {
if (checkResult && !checkAssignee && assigneesCheck.includes(it.login)) {
checkResult = true;
checkAssignee = true;
}
})
!checkAssignee ? checkResult = false : null;
}
if (!!checkResult && titleIncludes) {
const titleArr = titleIncludes.split('/');
const keyword1 = dealInput(titleArr[0]);
const keyword2 = dealInput(titleArr[1]);
checkResult =
keyword2.length ?
matchKeyword(issue.data.title, keyword1) && matchKeyword(issue.data.title, keyword2) :
matchKeyword(issue.data.title, keyword1);
}
if (!!checkResult && bodyIncludes) {
const bodyArr = bodyIncludes.split('/');
const keyword1 = dealInput(bodyArr[0]);
const keyword2 = dealInput(bodyArr[1]);
checkResult =
keyword2.length ?
matchKeyword(issue.data.body, keyword1) && matchKeyword(issue.data.body, keyword2) :
matchKeyword(issue.data.body, keyword1);
}
core.info(`Actions: [check-issue][${!!checkResult}] success!`);
core.setOutput("check-result", !!checkResult);
};
async function doCloseIssues (owner, repo, labels) {
const issues = await doQueryIssues(owner, repo, labels, 'open');
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
await doCloseIssue(owner, repo, issues[i].number);
if (core.getInput("body")) {
await doCreateComment(owner, repo, issues[i].number, core.getInput("body"));
}
}
} else {
core.info(`Actions: [query-issues] empty!`);
}
};
async function doFindComments (owner, repo, issueNumber) {
const res = await octokit.issues.listComments({
owner,
repo,
issue_number: issueNumber
});
core.info(`Actions: [find-comments][${issueNumber}] success!`);
let comments = [];
res.data.forEach(item => {
const a = commentAuth ? item.user.login === commentAuth : true;
const b = bodyIncludes ? item.body.includes(bodyIncludes) : true;
if (a && b) {
comments.push({
id: item.id,
auth: item.user.login,
body: item.body,
created: item.created_at,
updated: item.updated_at
})
if (direction === 'desc') {
comments.reverse();
}
}
})
core.setOutput("comments", comments);
};
async function doLockIssues (owner, repo, labels) {
const issues = await doQueryIssues(owner, repo, labels, issueState);
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
await doLockIssue(owner, repo, issues[i].number);
if (core.getInput("body")) {
await doCreateComment(owner, repo, issues[i].number, core.getInput("body"));
}
}
} else {
core.info(`Actions: [query-issues] empty!`);
}
};
async function doMonthStatistics (owner, repo, labels, assignees) {
const countLables = core.getInput("count-lables");
const countComments = core.getInput("count-comments");
const thisMonth = dayjs.utc().month() + 1;
const year = thisMonth == 1 ? dayjs.utc().year() - 1 : dayjs.utc().year();
const month = getPreMonth(thisMonth);
const showMonth = month < 10 ? `0${month}` : month;
let issues = await getIssuesInMonth(
owner,
repo,
thisMonth
);
if (issues.length == 0) {
core.info(`Actions: [query-issues-${month}] empty!`);
return false;
}
issues = issues.filter(i => {
return getCreatedMontn(i.created_at) == month
});
let total = issues.length;
let totalIssues = [...issues];
let openTotal = 0;
let openIssuesNumber = [];
let closeTotal = 0;
let closeIssuesNumber = [];
let labelsTotals = [];
const title = `[${owner}/${repo}] Month Statistics: ${year}-${showMonth}`;
for (let i = 0; i < issues.length; i++) {
if (issues[i].state == 'closed') {
closeTotal += 1;
closeIssuesNumber.push(issues[i].number);
} else if (issues[i].state == 'open') {
openTotal += 1;
openIssuesNumber.push(issues[i].number);
}
if (countLables && issues[i].labels) {
issues[i].labels.forEach(l => {
if (l.name in labelsTotals) {
labelsTotals[l.name] += 1;
} else {
labelsTotals[l.name] = 1;
}
})
}
}
let now = dayjs().utc().format('YYYY-MM-DD HH:mm:ss');
let body = `
- Created time: ${now}
- Time base: UTC +0
`;
let totalShow = `
### Count
| Total | Open | Closed |
| -- | -- | -- |
| ${total} | ${openTotal} | ${closeTotal} |
`;
body += totalShow;
if (countLables == 'true') {
let labelsArr = [];
for (var lab in labelsTotals) {
labelsArr.push({
labelName: lab,
number: labelsTotals[lab]
})
}
labelsArr.sort((a, b) => b.number - a.number);
let labelsTitle = `
### Labels statistics
<table>
<tr>
<th>Name</th>
<th>Number</th>
</tr>`
let labelsBody = '';
labelsArr.forEach(it => {
labelsBody += `<tr><td>${it.labelName}</td><td>${it.number}</td></tr>`
})
body = body + labelsTitle + labelsBody + `</table>
`;
}
if (countComments == 'true') {
totalIssues.sort((a, b) => b.comments - a.comments);
const maxComments = totalIssues.slice(0, 3);
let commentTitle = `
### Most comments
<table>
<tr>
<th>#</th>
<th>Issue</th>
<th>Title</th>
<th>Number</th>
<th>State</th>
</tr>
`
let commentBody = '';
maxComments.forEach((it,ind) => {
commentBody += `<tr>
<td>${ind + 1}</td>
<td>${it.number}</td>
<td>${it.title}</td>
<td>${it.comments}</td>
<td>${it.state}</td></tr>`
})
body = body + commentTitle + commentBody + '</table>';
}
await doCreateIssue(owner, repo, title, body, labels, assignees);
};
// Tool
async function doQueryIssues (owner, repo, labels, state, creator) {
let params = {
owner,
repo,
state,
};
issueCreator ? params.creator = issueCreator : null;
issueAssignee ? params.assignee = issueAssignee : null;
issueMentioned ? params.mentioned = issueMentioned : null;
if (labels) {
params.labels = labels;
}
if (creator) {
params.creator = creator;
}
const res = await getIssues(params);
let issues = [];
let issueNumbers = [];
if (res.length) {
res.forEach(iss => {
const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true;
const b = titleIncludes ? iss.title.includes(titleIncludes) : true;
/**
* Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request.
* For this reason, "Issues" endpoints may return both issues and pull requests in the response.
* You can identify pull requests by the pull_request key.
*/
if (a && b && iss.pull_request === undefined) {
if (inactiveDay) {
let lastTime = dayjs.utc().subtract(Number(inactiveDay), 'day');
let updateTime = dayjs.utc(iss.updated_at);
if (updateTime.isSameOrBefore(lastTime)) {
issues.push(iss);
issueNumbers.push(iss.number);
}
} else {
issues.push(iss);
issueNumbers.push(iss.number);
}
}
})
core.info(`Actions: [query-issues]: [${JSON.stringify(issueNumbers)}]!`);
}
return issues;
};
async function getIssues (params, page = 1) {
let { data: issues } = await octokit.issues.listForRepo({
...params,
per_page: perPage,
page
});
if (issues.length >= perPage) {
issues = issues.concat(await getIssues(params, page + 1));
}
return issues;
};
async function getIssuesInMonth (owner, repo, thisMonth, page = 1) {
const month = getPreMonth(thisMonth);
let { data: issues } = await octokit.issues.listForRepo({
owner,
repo,
state: 'all',
per_page: perPage,
page
});
issues = issues.filter(i => {
return i.pull_request === undefined
});
if (issues.length && getCreatedMontn(issues[issues.length - 1].created_at) >= month) {
issues = issues.concat(await getIssuesInMonth(owner, repo, thisMonth, page + 1));
}
return issues;
};
// tool
function testContent(con) {
if (ALLREACTIONS.includes(con)) {
return true;
} else {
core.setFailed("This actions not supported!");
return false;
}
};
function getCreatedMontn (d) {
return dayjs(d).utc().month() + 1;
};
// exports
module.exports = {
// base
doAddAssignees,
doAddLabels,
doCloseIssue,
doCreateComment,
doCreateCommentContent,
doCreateIssue,
doCreateIssueContent,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
doOpenIssue,
doRemoveAssignees,
doRemoveLabels,
doSetLabels,
doUnlockIssue,
doUpdateComment,
doUpdateIssue,
doWelcome,
// advanced
doCheckInactive,
doCheckIssue,
doCloseIssues,
doFindComments,
doLockIssues,
doMonthStatistics,
};

112
src/less/dumi.less Normal file

File diff suppressed because one or more lines are too long

3
src/less/main.less Normal file
View File

@@ -0,0 +1,3 @@
html {
scroll-behavior: smooth;
}

20
src/less/markdown.less Normal file
View File

@@ -0,0 +1,20 @@
.markdown table {
width: auto !important;
a:hover {
text-decoration: none;
}
}
.markdown table td:first-child {
font-weight: normal !important;
}
code {
padding: 1px 5px !important;
border-radius: 4px;
color: #ff7875 !important;
background: rgba(0, 0, 0, 0.06) !important;
box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
border: 1px solid rgba(0,0,0,0.1);
}

View File

@@ -1,15 +1,14 @@
const core = require("@actions/core");
const github = require("@actions/github");
const core = require('@actions/core');
const github = require('@actions/github');
// **************************************************************************
const {
// base
doAddAssignees,
doAddLabels,
doCloseIssue,
doCreateComment,
doCreateCommentContent,
doCreateIssue,
doCreateIssueContent,
doCreateLabel,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
@@ -21,16 +20,18 @@ const {
doUpdateComment,
doUpdateIssue,
doWelcome,
} = require('./base.js');
// advanced
const {
doCheckInactive,
doCheckIssue,
doCloseIssues,
doFindComments,
doLockIssues,
doMonthStatistics,
} = require('./do.js');
} = require('./advanced.js');
// **************************************************************************
const ALLACTIONS = [
// base
'add-assignees',
@@ -38,6 +39,7 @@ const ALLACTIONS = [
'close-issue',
'create-comment',
'create-issue',
'create-label',
'delete-comment',
'lock-issue',
'mark-duplicate',
@@ -59,6 +61,7 @@ const ALLACTIONS = [
'month-statistics',
];
// **************************************************************************
async function main() {
try {
const owner = github.context.repo.owner;
@@ -67,24 +70,24 @@ async function main() {
const issueNumber = core.getInput('issue-number');
const commentId = core.getInput('comment-id');
const defaultBody = `Currently at ${owner}/${repo}. And this is default comment.`
const body = core.getInput("body") || defaultBody;
const defaultBody = `Currently at ${owner}/${repo}. And this is default comment.`;
const body = core.getInput('body') || defaultBody;
const defaultTitle = `Default Title`;
const title = core.getInput("title") || defaultTitle;
const title = core.getInput('title') || defaultTitle;
const assignees = core.getInput("assignees");
const assignees = core.getInput('assignees');
const labels = core.getInput("labels");
const state = core.getInput("state") || 'open';
const labels = core.getInput('labels');
const state = core.getInput('state') || 'open';
let updateMode = core.getInput("update-mode");
let updateMode = core.getInput('update-mode');
if (updateMode !== 'append') {
updateMode = 'replace';
}
// actions
const actions = core.getInput("actions", { required: true });
const actions = core.getInput('actions', { required: true });
const actionsArr = actions.split(',');
actionsArr.forEach(item => {
@@ -95,9 +98,9 @@ async function main() {
if (ALLACTIONS.includes(action)) {
choseActions(action);
} else {
core.setFailed("This actions not supported!");
core.setFailed('This actions not supported!');
}
};
}
async function choseActions(action) {
switch (action) {
@@ -117,6 +120,9 @@ async function main() {
case 'create-issue':
await doCreateIssue(owner, repo, title, body, labels, assignees);
break;
case 'create-label':
await doCreateLabel(owner, repo);
break;
case 'delete-comment':
await doDeleteComment(owner, repo, commentId);
break;
@@ -142,13 +148,7 @@ async function main() {
await doUnlockIssue(owner, repo, issueNumber);
break;
case 'update-comment':
await doUpdateComment(
owner,
repo,
commentId,
body,
updateMode
);
await doUpdateComment(owner, repo, commentId, body, updateMode);
break;
case 'update-issue':
await doUpdateIssue(
@@ -160,72 +160,41 @@ async function main() {
body,
updateMode,
assignees,
labels
labels,
);
break;
case 'welcome':
await doWelcome(
owner,
repo,
assignees,
labels,
body
);
await doWelcome(owner, repo, assignees, labels, body);
break;
// advanced
case 'check-inactive':
await doCheckInactive(
owner,
repo,
labels
)
await doCheckInactive(owner, repo, labels);
break;
case 'check-issue':
await doCheckIssue(
owner,
repo,
issueNumber
);
await doCheckIssue(owner, repo, issueNumber);
break;
case 'close-issues':
await doCloseIssues(
owner,
repo,
labels
)
await doCloseIssues(owner, repo, labels);
break;
case 'find-comments':
await doFindComments(
owner,
repo,
issueNumber
);
await doFindComments(owner, repo, issueNumber);
break;
case 'lock-issues':
await doLockIssues(
owner,
repo,
labels
);
await doLockIssues(owner, repo, labels);
break;
case 'month-statistics':
await doMonthStatistics(
owner,
repo,
labels,
assignees
);
await doMonthStatistics(owner, repo, labels, assignees);
break;
// default
default:
break;
}
};
}
catch (error) {
}
} catch (error) {
core.setFailed(error.message);
}
}
// **************************************************************************
main();

126
src/public.js Normal file
View File

@@ -0,0 +1,126 @@
require('dotenv').config();
const core = require('@actions/core');
const { Octokit } = require('@octokit/rest');
const { getPreMonth } = require('./util.js');
// **************************************************************************
var dayjs = require('dayjs');
var utc = require('dayjs/plugin/utc');
dayjs.extend(utc);
var isSameOrBefore = require('dayjs/plugin/isSameOrBefore');
dayjs.extend(isSameOrBefore);
// **************************************************************************
const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
const perPage = 100;
const issueCreator = core.getInput('issue-creator');
const issueAssignee = core.getInput('issue-assignee');
const issueMentioned = core.getInput('issue-mentioned');
const bodyIncludes = core.getInput('body-includes');
const titleIncludes = core.getInput('title-includes');
const inactiveDay = core.getInput('inactive-day');
// **************************************************************************
async function doQueryIssues(owner, repo, labels, state, creator) {
let params = {
owner,
repo,
state,
};
issueCreator ? (params.creator = issueCreator) : null;
issueAssignee ? (params.assignee = issueAssignee) : null;
issueMentioned ? (params.mentioned = issueMentioned) : null;
if (labels) {
params.labels = labels;
}
if (creator) {
params.creator = creator;
}
const res = await getIssues(params);
let issues = [];
let issueNumbers = [];
if (res.length) {
res.forEach(iss => {
const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true;
const b = titleIncludes ? iss.title.includes(titleIncludes) : true;
/**
* Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request.
* For this reason, "Issues" endpoints may return both issues and pull requests in the response.
* You can identify pull requests by the pull_request key.
*/
if (a && b && iss.pull_request === undefined) {
if (inactiveDay) {
let lastTime = dayjs.utc().subtract(Number(inactiveDay), 'day');
let updateTime = dayjs.utc(iss.updated_at);
if (updateTime.isSameOrBefore(lastTime)) {
issues.push(iss);
issueNumbers.push(iss.number);
}
} else {
issues.push(iss);
issueNumbers.push(iss.number);
}
}
});
core.info(`Actions: [query-issues]: [${JSON.stringify(issueNumbers)}]!`);
}
return issues;
}
async function getIssues(params, page = 1) {
let { data: issues } = await octokit.issues.listForRepo({
...params,
per_page: perPage,
page,
});
if (issues.length >= perPage) {
issues = issues.concat(await getIssues(params, page + 1));
}
return issues;
}
async function getIssuesInMonth(owner, repo, thisMonth, page = 1) {
const month = getPreMonth(thisMonth);
let { data: issues } = await octokit.issues.listForRepo({
owner,
repo,
state: 'all',
per_page: perPage,
page,
});
issues = issues.filter(i => {
return i.pull_request === undefined;
});
if (issues.length && getCreatedMonth(issues[issues.length - 1].created_at) >= month) {
issues = issues.concat(await getIssuesInMonth(owner, repo, thisMonth, page + 1));
}
return issues;
}
// **************************************************************************
function getCreatedMonth(d) {
return (
dayjs(d)
.utc()
.month() + 1
);
}
// **************************************************************************
module.exports = {
doQueryIssues,
getIssues,
getIssuesInMonth,
getCreatedMonth,
};

View File

@@ -1,23 +1,37 @@
function dealInput (para) {
const sampleSize = require('lodash/sampleSize');
function dealStringToArr(para) {
/**
* in 'x1,x2,x3'
* out ['x1','x2','x3']
*/
let arr = [];
if (para) {
const paraArr = para.split(',');
paraArr.forEach(it => {
if(it.trim()){
arr.push(it.trim())
if (it.trim()) {
arr.push(it.trim());
}
})
});
}
return arr;
};
}
function matchKeyword (content, keywords) {
function dealRandomAssignees(assignees, randomTo) {
let arr = dealStringToArr(assignees);
if (randomTo && Number(randomTo) > 0 && Number(randomTo) < arr.length) {
arr = sampleSize(arr, randomTo);
}
return arr;
}
function matchKeyword(content, keywords) {
return keywords.find(item => content.toLowerCase().includes(item));
};
}
function testDuplicate(body) {
if (!body || !body.startsWith('Duplicate of')) {
return false
return false;
}
let arr = body.split(' ');
@@ -26,15 +40,29 @@ function testDuplicate(body) {
} else {
return false;
}
};
}
function getPreMonth (m) {
return m == 1 ? 12 : m -1;
};
function getPreMonth(m) {
return m == 1 ? 12 : m - 1;
}
function checkPermission(require, permission) {
/**
* 有权限返回 true
*/
const permissions = ['none', 'read', 'write', 'admin'];
const requireNo = permissions.indexOf(require);
const permissionNo = permissions.indexOf(permission);
return requireNo <= permissionNo;
}
// **********************************************************
module.exports = {
dealInput,
dealStringToArr,
dealRandomAssignees,
getPreMonth,
matchKeyword,
testDuplicate,
checkPermission,
};

13126
yarn.lock Normal file

File diff suppressed because it is too large Load Diff