mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 18:25:58 +08:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b7db679f4b | ||
![]() |
0cbadbacfa | ||
![]() |
1ce7be88a0 | ||
![]() |
53dda7f0e4 | ||
![]() |
026e812e04 | ||
![]() |
986730477b | ||
![]() |
9984ee0402 | ||
![]() |
dae9d88636 | ||
![]() |
7879d79201 | ||
![]() |
ed1da6607e |
5
.github/PULL_REQUEST_TEMPLATE.md
vendored
5
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -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. ⚠️
|
||||
|
27
.github/workflows/check-dist.yml
vendored
27
.github/workflows/check-dist.yml
vendored
@@ -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
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -18,7 +18,7 @@ yarn-error.log*
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
yarn.lock
|
||||
# yarn.lock
|
||||
package-lock.json
|
||||
|
||||
# local env files
|
||||
|
19
.umirc.ts
19
.umirc.ts
@@ -47,9 +47,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 +65,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;
|
||||
}
|
||||
`,
|
||||
]
|
||||
});
|
||||
|
@@ -1,3 +1,12 @@
|
||||
## 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`
|
||||
|
124
README.en-US.md
124
README.en-US.md
@@ -75,7 +75,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Add assigness
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'add-assignees'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -94,7 +94,7 @@ jobs:
|
||||
- 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 +115,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@v1.8
|
||||
with:
|
||||
actions: 'add-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -140,7 +140,7 @@ Close the specified issue.
|
||||
|
||||
```yml
|
||||
- name: Close issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'close-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -173,7 +173,7 @@ jobs:
|
||||
if: github.event.label.name == 'xxx'
|
||||
steps:
|
||||
- name: Create comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -217,7 +217,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -249,7 +249,7 @@ 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@v1.8
|
||||
with:
|
||||
actions: 'delete-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -281,7 +281,7 @@ jobs:
|
||||
if: github.event.label.name == 'invalid'
|
||||
steps:
|
||||
- name: Lock issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'lock-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -312,7 +312,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: mark-duplicate
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'mark-duplicate'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -324,6 +324,7 @@ 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 | ✖ |
|
||||
@@ -339,7 +340,7 @@ Open the specified issue.
|
||||
|
||||
```yml
|
||||
- name: Open issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'open-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -360,7 +361,7 @@ Remove the person designated by issue.
|
||||
|
||||
```yml
|
||||
- name: Remove assignees
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'remove-assignees'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -383,7 +384,7 @@ Remove the specified labels.
|
||||
|
||||
```yml
|
||||
- name: Remove labels
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'remove-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -408,7 +409,7 @@ Replace the labels of issue.
|
||||
|
||||
```yml
|
||||
- name: Set labels
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'set-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -431,7 +432,7 @@ Unlock the specified issue.
|
||||
|
||||
```yml
|
||||
- name: Unlock issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'unlock-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -464,7 +465,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Update comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'update-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -492,7 +493,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@v1.8
|
||||
with:
|
||||
actions: 'update-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -542,7 +543,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: welcome
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'welcome'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -585,7 +586,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: check-inactive
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'check-inactive'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -638,7 +639,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: check-issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'check-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -657,7 +658,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 +678,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: close-issues
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'close-issues'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -711,7 +712,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@v1.8
|
||||
with:
|
||||
actions: 'find-comments'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -759,7 +760,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: lock-issues
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'lock-issues'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -805,7 +806,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: month-statistics
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'month-statistics'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -848,7 +849,7 @@ jobs:
|
||||
if: github.event.label.name == 'watch'
|
||||
steps:
|
||||
- name: find comments
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
id: fcid
|
||||
with:
|
||||
actions: 'find-comments'
|
||||
@@ -859,7 +860,7 @@ jobs:
|
||||
|
||||
- name: create comment
|
||||
if: ${{ steps.fcid.outputs.comments.length == 0 }}
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -868,7 +869,7 @@ jobs:
|
||||
|
||||
- name: update comment
|
||||
if: ${{ steps.fcid.outputs.comments.length == 1 }}
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'update-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -900,7 +901,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@v1.8
|
||||
id: createissue
|
||||
with:
|
||||
actions: 'create-issue'
|
||||
@@ -1000,31 +1001,50 @@ At the same time, if you have any questions during use, you can also ask and inq
|
||||
|
||||
<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>
|
||||
<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" />
|
||||
<br />
|
||||
ant-design
|
||||
</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" />
|
||||
<br />
|
||||
ant-design-vue
|
||||
</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" />
|
||||
<br />
|
||||
dumi
|
||||
</a></td>
|
||||
<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" />
|
||||
<br />
|
||||
material-ui
|
||||
</a></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>
|
||||
<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" />
|
||||
<br />
|
||||
react-music-player
|
||||
</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" />
|
||||
<br />
|
||||
umi
|
||||
</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" />
|
||||
<br />
|
||||
vue-request
|
||||
</a></td>
|
||||
<td align="center" width="180"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
122
README.md
122
README.md
@@ -75,7 +75,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Add assigness
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'add-assignees'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -115,7 +115,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@v1.8
|
||||
with:
|
||||
actions: 'add-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -140,7 +140,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Close issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'close-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -173,7 +173,7 @@ jobs:
|
||||
if: github.event.label.name == 'xxx'
|
||||
steps:
|
||||
- name: Create comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -217,7 +217,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -249,7 +249,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Delete comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'delete-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -281,7 +281,7 @@ jobs:
|
||||
if: github.event.label.name == 'invalid'
|
||||
steps:
|
||||
- name: Lock issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'lock-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -312,7 +312,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: mark-duplicate
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'mark-duplicate'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -324,6 +324,7 @@ 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 | ✖ |
|
||||
@@ -339,7 +340,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Open issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'open-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -360,7 +361,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Remove assignees
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'remove-assignees'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -383,7 +384,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Remove labels
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'remove-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -408,7 +409,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Set labels
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'set-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -431,7 +432,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Unlock issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'unlock-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -464,7 +465,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Update comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'update-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -492,7 +493,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Update issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'update-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -540,7 +541,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: welcome
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'welcome'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -583,7 +584,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: check-inactive
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'check-inactive'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -632,7 +633,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: check-issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'check-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -651,7 +652,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 +672,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: close-issues
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'close-issues'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -705,7 +706,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Find comments
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'find-comments'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -753,7 +754,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: lock-issues
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'lock-issues'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -799,7 +800,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: month-statistics
|
||||
uses: actions-cool/issues-helper@v1.7.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'month-statistics'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -842,7 +843,7 @@ jobs:
|
||||
if: github.event.label.name == 'watch'
|
||||
steps:
|
||||
- name: find comments
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
id: fcid
|
||||
with:
|
||||
actions: 'find-comments'
|
||||
@@ -853,7 +854,7 @@ jobs:
|
||||
|
||||
- name: create comment
|
||||
if: ${{ steps.fcid.outputs.comments.length == 0 }}
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -862,7 +863,7 @@ jobs:
|
||||
|
||||
- name: update comment
|
||||
if: ${{ steps.fcid.outputs.comments.length == 1 }}
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'update-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -894,7 +895,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Create issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
id: createissue
|
||||
with:
|
||||
actions: 'create-issue'
|
||||
@@ -995,31 +996,50 @@ x2 + y2
|
||||
|
||||
<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>
|
||||
<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" />
|
||||
<br />
|
||||
ant-design
|
||||
</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" />
|
||||
<br />
|
||||
ant-design-vue
|
||||
</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" />
|
||||
<br />
|
||||
dumi
|
||||
</a></td>
|
||||
<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" />
|
||||
<br />
|
||||
material-ui
|
||||
</a></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>
|
||||
<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" />
|
||||
<br />
|
||||
react-music-player
|
||||
</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" />
|
||||
<br />
|
||||
umi
|
||||
</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" />
|
||||
<br />
|
||||
vue-request
|
||||
</a></td>
|
||||
<td align="center" width="180"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
42
USERS.js
Normal file
42
USERS.js
Normal file
@@ -0,0 +1,42 @@
|
||||
// **************************************************************************
|
||||
|
||||
// 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'
|
||||
},
|
||||
];
|
||||
|
||||
// **************************************************************************
|
||||
|
||||
module.exports = {
|
||||
users
|
||||
};
|
||||
|
||||
// **************************************************************************
|
@@ -56,6 +56,8 @@ inputs:
|
||||
description: 'For mark-duplicate'
|
||||
duplicate-labels:
|
||||
description: 'For mark-duplicate add labels'
|
||||
remove-labels:
|
||||
description: 'For remove labels'
|
||||
close-issue:
|
||||
description: 'For mark-duplicate'
|
||||
count-lables:
|
||||
|
859
dist/index.js
vendored
859
dist/index.js
vendored
@@ -6022,7 +6022,320 @@ function wrappy (fn, cb) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9075:
|
||||
/***/ 9319:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
__webpack_require__(2437).config();
|
||||
const core = __webpack_require__(2186);
|
||||
const { Octokit } = __webpack_require__(5375);
|
||||
|
||||
const {
|
||||
doAddLabels,
|
||||
doCreateComment,
|
||||
doCloseIssue,
|
||||
doLockIssue,
|
||||
doCreateIssue,
|
||||
} = __webpack_require__(9932);
|
||||
|
||||
const {
|
||||
doQueryIssues,
|
||||
getIssuesInMonth,
|
||||
getCreatedMonth,
|
||||
} = __webpack_require__(197);
|
||||
|
||||
const {
|
||||
dealInput,
|
||||
matchKeyword,
|
||||
getPreMonth
|
||||
} = __webpack_require__(6254);
|
||||
|
||||
// **************************************************************************
|
||||
var dayjs = __webpack_require__(7401);
|
||||
var utc = __webpack_require__(4359);
|
||||
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 = 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 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,
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9932:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
__webpack_require__(2437).config();
|
||||
@@ -6030,12 +6343,7 @@ const core = __webpack_require__(2186);
|
||||
const github = __webpack_require__(5438);
|
||||
const { Octokit } = __webpack_require__(5375);
|
||||
|
||||
var dayjs = __webpack_require__(7401);
|
||||
var utc = __webpack_require__(4359);
|
||||
dayjs.extend(utc);
|
||||
var isSameOrBefore = __webpack_require__(9517);
|
||||
dayjs.extend(isSameOrBefore);
|
||||
|
||||
// **************************************************************************
|
||||
const ALLREACTIONS = [
|
||||
"+1",
|
||||
"-1",
|
||||
@@ -6047,46 +6355,23 @@ const ALLREACTIONS = [
|
||||
"eyes",
|
||||
];
|
||||
|
||||
const {
|
||||
doQueryIssues
|
||||
} = __webpack_require__(197);
|
||||
|
||||
const {
|
||||
dealInput,
|
||||
matchKeyword,
|
||||
testDuplicate,
|
||||
getPreMonth
|
||||
} = __webpack_require__(6254);
|
||||
|
||||
// **************************************************************************
|
||||
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
|
||||
const contents = core.getInput("contents");
|
||||
|
||||
// **************************************************************************
|
||||
async function doAddAssignees (owner, repo, issueNumber, assignees) {
|
||||
await octokit.issues.addAssignees({
|
||||
owner,
|
||||
@@ -6213,6 +6498,7 @@ async function doMarkDuplicate (owner, repo, labels) {
|
||||
|
||||
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 commentId = context.payload.comment.id;
|
||||
@@ -6231,6 +6517,9 @@ async function doMarkDuplicate (owner, repo, labels) {
|
||||
if (duplicateLabels) {
|
||||
await doAddLabels(owner, repo, issueNumber, duplicateLabels);
|
||||
}
|
||||
if (removeLables) {
|
||||
await doRemoveLabels(owner, repo, issueNumber, removeLables);
|
||||
}
|
||||
if (labels) {
|
||||
await doSetLabels(owner, repo, issueNumber, labels);
|
||||
}
|
||||
@@ -6408,6 +6697,7 @@ async function doUpdateIssue (
|
||||
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 {
|
||||
@@ -6439,336 +6729,7 @@ async function doWelcome (owner, repo, assignees, labels, body) {
|
||||
}
|
||||
};
|
||||
|
||||
// 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;
|
||||
@@ -6778,13 +6739,8 @@ function testContent(con) {
|
||||
}
|
||||
};
|
||||
|
||||
function getCreatedMontn (d) {
|
||||
return dayjs(d).utc().month() + 1;
|
||||
};
|
||||
|
||||
// exports
|
||||
// **************************************************************************
|
||||
module.exports = {
|
||||
// base
|
||||
doAddAssignees,
|
||||
doAddLabels,
|
||||
doCloseIssue,
|
||||
@@ -6803,14 +6759,6 @@ module.exports = {
|
||||
doUpdateComment,
|
||||
doUpdateIssue,
|
||||
doWelcome,
|
||||
|
||||
// advanced
|
||||
doCheckInactive,
|
||||
doCheckIssue,
|
||||
doCloseIssues,
|
||||
doFindComments,
|
||||
doLockIssues,
|
||||
doMonthStatistics,
|
||||
};
|
||||
|
||||
|
||||
@@ -6822,15 +6770,13 @@ module.exports = {
|
||||
const core = __webpack_require__(2186);
|
||||
const github = __webpack_require__(5438);
|
||||
|
||||
// **************************************************************************
|
||||
const {
|
||||
// base
|
||||
doAddAssignees,
|
||||
doAddLabels,
|
||||
doCloseIssue,
|
||||
doCreateComment,
|
||||
doCreateCommentContent,
|
||||
doCreateIssue,
|
||||
doCreateIssueContent,
|
||||
doDeleteComment,
|
||||
doMarkDuplicate,
|
||||
doLockIssue,
|
||||
@@ -6842,16 +6788,18 @@ const {
|
||||
doUpdateComment,
|
||||
doUpdateIssue,
|
||||
doWelcome,
|
||||
} = __webpack_require__(9932);
|
||||
|
||||
// advanced
|
||||
const {
|
||||
doCheckInactive,
|
||||
doCheckIssue,
|
||||
doCloseIssues,
|
||||
doFindComments,
|
||||
doLockIssues,
|
||||
doMonthStatistics,
|
||||
} = __webpack_require__(9075);
|
||||
} = __webpack_require__(9319);
|
||||
|
||||
// **************************************************************************
|
||||
const ALLACTIONS = [
|
||||
// base
|
||||
'add-assignees',
|
||||
@@ -6880,6 +6828,7 @@ const ALLACTIONS = [
|
||||
'month-statistics',
|
||||
];
|
||||
|
||||
// **************************************************************************
|
||||
async function main() {
|
||||
try {
|
||||
const owner = github.context.repo.owner;
|
||||
@@ -7049,15 +6998,151 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
main();
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 197:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
__webpack_require__(2437).config();
|
||||
const core = __webpack_require__(2186);
|
||||
const { Octokit } = __webpack_require__(5375);
|
||||
|
||||
const {
|
||||
getPreMonth
|
||||
} = __webpack_require__(6254);
|
||||
|
||||
// **************************************************************************
|
||||
var dayjs = __webpack_require__(7401);
|
||||
var utc = __webpack_require__(4359);
|
||||
dayjs.extend(utc);
|
||||
var isSameOrBefore = __webpack_require__(9517);
|
||||
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,
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 6254:
|
||||
/***/ ((module) => {
|
||||
|
||||
function dealInput (para) {
|
||||
/**
|
||||
* in 'x1,x2,x3'
|
||||
* out ['x1','x2','x3']
|
||||
*/
|
||||
let arr = [];
|
||||
if (para) {
|
||||
const paraArr = para.split(',');
|
||||
|
@@ -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@v1.8
|
||||
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@v1.8
|
||||
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@v1.8
|
||||
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@v1.8
|
||||
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@v1.8
|
||||
with:
|
||||
actions: 'lock-issues'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -232,7 +232,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: month-statistics
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'month-statistics'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -251,3 +251,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:
|
||||
|
||||

|
||||
|
@@ -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@v1.8
|
||||
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@v1.8
|
||||
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@v1.8
|
||||
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@v1.8
|
||||
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@v1.8
|
||||
with:
|
||||
actions: 'lock-issues'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -228,7 +228,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: month-statistics
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'month-statistics'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -238,7 +238,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 +247,7 @@ jobs:
|
||||
- 新增 `issue` 的标题默认为 `[当前仓库] Month Statistics: 年-月`
|
||||
- `count-lables`:可设置 `'true'`,增加 labels 统计
|
||||
- `count-comments`:可设置 `'true'`,增加 comments 统计
|
||||
|
||||
如下所示:
|
||||
|
||||

|
||||
|
@@ -22,7 +22,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Add assigness
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'add-assignees'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -60,7 +60,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@v1.8
|
||||
with:
|
||||
actions: 'add-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -83,7 +83,7 @@ Close the specified issue.
|
||||
|
||||
```yml
|
||||
- name: Close issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'close-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -114,7 +114,7 @@ jobs:
|
||||
if: github.event.label.name == 'xxx'
|
||||
steps:
|
||||
- name: Create comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -156,7 +156,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -186,7 +186,7 @@ According to [`comment-id`](/en-US/guide/ref#-comment-id) delete the specified c
|
||||
|
||||
```yml
|
||||
- name: Delete comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'delete-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -216,7 +216,7 @@ jobs:
|
||||
if: github.event.label.name == 'invalid'
|
||||
steps:
|
||||
- name: Lock issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'lock-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -245,7 +245,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: mark-duplicate
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'mark-duplicate'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -257,6 +257,7 @@ 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 | ✖ |
|
||||
@@ -276,7 +277,7 @@ Open the specified issue.
|
||||
|
||||
```yml
|
||||
- name: Open issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'open-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -295,7 +296,7 @@ Remove the person designated by issue.
|
||||
|
||||
```yml
|
||||
- name: Remove assignees
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'remove-assignees'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -316,7 +317,7 @@ Remove the specified labels.
|
||||
|
||||
```yml
|
||||
- name: Remove labels
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'remove-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -339,7 +340,7 @@ Replace the labels of issue.
|
||||
|
||||
```yml
|
||||
- name: Set labels
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'set-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -360,7 +361,7 @@ Unlock the specified issue.
|
||||
|
||||
```yml
|
||||
- name: Unlock issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'unlock-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -391,7 +392,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Update comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'update-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -417,7 +418,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@v1.8
|
||||
with:
|
||||
actions: 'update-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -465,7 +466,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: welcome
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'welcome'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
33
docs/base.md
33
docs/base.md
@@ -22,7 +22,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Add assigness
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'add-assignees'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -60,7 +60,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@v1.8
|
||||
with:
|
||||
actions: 'add-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -83,7 +83,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Close issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'close-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -114,7 +114,7 @@ jobs:
|
||||
if: github.event.label.name == 'xxx'
|
||||
steps:
|
||||
- name: Create comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -156,7 +156,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'create-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -186,7 +186,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Delete comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'delete-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -216,7 +216,7 @@ jobs:
|
||||
if: github.event.label.name == 'invalid'
|
||||
steps:
|
||||
- name: Lock issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'lock-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -245,7 +245,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: mark-duplicate
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'mark-duplicate'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -257,6 +257,7 @@ 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 | ✖ |
|
||||
@@ -276,7 +277,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Open issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'open-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -295,7 +296,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Remove assignees
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'remove-assignees'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -316,7 +317,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Remove labels
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'remove-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -339,7 +340,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Set labels
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'set-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -360,7 +361,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Unlock issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'unlock-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -391,7 +392,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Update comment
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'update-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -417,7 +418,7 @@ jobs:
|
||||
|
||||
```yml
|
||||
- name: Update issue
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'update-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -464,7 +465,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: welcome
|
||||
uses: actions-cool/issues-helper@v1.7
|
||||
uses: actions-cool/issues-helper@v1.8
|
||||
with:
|
||||
actions: 'welcome'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
24
docs/guide/note.en-US.md
Normal file
24
docs/guide/note.en-US.md
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
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).
|
||||
|
||||
## `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.
|
25
docs/guide/note.md
Normal file
25
docs/guide/note.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
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)。
|
||||
|
||||
## `GitHub Actions bot` 触发
|
||||
|
||||
当设置了一个 Actions,如为给一个 issue 新增 label `x1` 时,Actions 自动为该 issue 增加 `x2` label。
|
||||
|
||||
但如果这个是由 `GitHub Actions bot` 完成的(即 actions 中 token 不传,或使用默认 `token: ${{ secrets.GITHUB_TOKEN }}`),则不会触发 label `x2` 的 Actions。
|
@@ -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@v1.8
|
||||
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#L997-L1044"></embed>
|
||||
|
||||
## ⚡ Feedback
|
||||
|
||||
|
@@ -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@v1.8
|
||||
with:
|
||||
actions: 'create-comment'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
|
||||
## 💖 谁在使用?
|
||||
|
||||
<embed src="../README.md#L996-L1024"></embed>
|
||||
<embed src="../README.md#L997-L1044"></embed>
|
||||
|
||||
## ⚡ 反馈
|
||||
|
||||
|
@@ -11,8 +11,9 @@
|
||||
"docs:deploy": "gh-pages -d docs-dist",
|
||||
"deploy": "npm run docs:build && npm run docs:deploy",
|
||||
"package": "ncc build src/main.js -o dist",
|
||||
"update": "node ./script/update-user.js",
|
||||
"main": "node ./src/main.js"
|
||||
"up-users": "node ./script/update-users.js",
|
||||
"main": "node ./src/main.js",
|
||||
"up-version": "node ./script/update-version.js"
|
||||
},
|
||||
"author": "xrkffgg",
|
||||
"license": "MIT",
|
||||
|
BIN
public/month.png
Normal file
BIN
public/month.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
@@ -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 ``
|
||||
};
|
||||
|
||||
// **************************************************************************
|
81
script/update-users.js
Normal file
81
script/update-users.js
Normal file
@@ -0,0 +1,81 @@
|
||||
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 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" />
|
||||
<br />
|
||||
${getName(o)}
|
||||
</a>`
|
||||
}
|
||||
return ``
|
||||
};
|
||||
|
||||
function getName (o) {
|
||||
if (o) {
|
||||
return o.url.split('/').slice(-1)[0]
|
||||
}
|
||||
return ``
|
||||
};
|
||||
|
||||
// **************************************************************************
|
44
script/update-version.js
Normal file
44
script/update-version.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const { readFileSync, writeFileSync } = require('fs');
|
||||
|
||||
const last = /v1\.7/g;
|
||||
const now = 'v1.8';
|
||||
|
||||
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!');
|
306
src/advanced.js
Normal file
306
src/advanced.js
Normal file
@@ -0,0 +1,306 @@
|
||||
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 {
|
||||
dealInput,
|
||||
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 = 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 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
4
src/app.jsx
Normal file
@@ -0,0 +1,4 @@
|
||||
// Just for dumi style
|
||||
import './less/main.less';
|
||||
import './less/markdown.less';
|
||||
import './less/dumi.less';
|
422
src/base.js
Normal file
422
src/base.js
Normal file
@@ -0,0 +1,422 @@
|
||||
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 {
|
||||
dealInput,
|
||||
testDuplicate,
|
||||
} = require('./util.js');
|
||||
|
||||
// **************************************************************************
|
||||
const token = core.getInput('token');
|
||||
const octokit = new Octokit({ auth: `token ${token}` });
|
||||
const context = github.context;
|
||||
|
||||
const contents = core.getInput("contents");
|
||||
|
||||
// **************************************************************************
|
||||
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 removeLables = core.getInput("remove-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 (removeLables) {
|
||||
await doRemoveLabels(owner, repo, issueNumber, removeLables);
|
||||
}
|
||||
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;
|
||||
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, dealInput(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,
|
||||
doDeleteComment,
|
||||
doMarkDuplicate,
|
||||
doLockIssue,
|
||||
doOpenIssue,
|
||||
doRemoveAssignees,
|
||||
doRemoveLabels,
|
||||
doSetLabels,
|
||||
doUnlockIssue,
|
||||
doUpdateComment,
|
||||
doUpdateIssue,
|
||||
doWelcome,
|
||||
};
|
787
src/do.js
787
src/do.js
@@ -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,
|
||||
};
|
56
src/less/dumi.less
Normal file
56
src/less/dumi.less
Normal file
File diff suppressed because one or more lines are too long
3
src/less/main.less
Normal file
3
src/less/main.less
Normal file
@@ -0,0 +1,3 @@
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
15
src/less/markdown.less
Normal file
15
src/less/markdown.less
Normal file
@@ -0,0 +1,15 @@
|
||||
.markdown table {
|
||||
width: auto !important;
|
||||
}
|
||||
|
||||
.markdown table td:first-child {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 1px 5px !important;
|
||||
border-radius: 4px;
|
||||
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);
|
||||
}
|
12
src/main.js
12
src/main.js
@@ -1,15 +1,13 @@
|
||||
const core = require("@actions/core");
|
||||
const github = require("@actions/github");
|
||||
|
||||
// **************************************************************************
|
||||
const {
|
||||
// base
|
||||
doAddAssignees,
|
||||
doAddLabels,
|
||||
doCloseIssue,
|
||||
doCreateComment,
|
||||
doCreateCommentContent,
|
||||
doCreateIssue,
|
||||
doCreateIssueContent,
|
||||
doDeleteComment,
|
||||
doMarkDuplicate,
|
||||
doLockIssue,
|
||||
@@ -21,16 +19,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',
|
||||
@@ -59,6 +59,7 @@ const ALLACTIONS = [
|
||||
'month-statistics',
|
||||
];
|
||||
|
||||
// **************************************************************************
|
||||
async function main() {
|
||||
try {
|
||||
const owner = github.context.repo.owner;
|
||||
@@ -228,4 +229,5 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
main();
|
||||
|
124
src/public.js
Normal file
124
src/public.js
Normal file
@@ -0,0 +1,124 @@
|
||||
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,
|
||||
};
|
@@ -1,4 +1,8 @@
|
||||
function dealInput (para) {
|
||||
/**
|
||||
* in 'x1,x2,x3'
|
||||
* out ['x1','x2','x3']
|
||||
*/
|
||||
let arr = [];
|
||||
if (para) {
|
||||
const paraArr = para.split(',');
|
||||
|
Reference in New Issue
Block a user