Compare commits

..

14 Commits

Author SHA1 Message Date
xrkffgg
39ff3699d6 docs: up v2.1.2 2021-02-19 18:00:41 +08:00
xrkffgg
efca7df548 feat: update/delete comment support find-comments out (#63)
* fix: find comments

* add out

* add more

* add

* add doc

* fix link

* perf

* update doc

* Update gh-pages.yml

* Update .github/workflows/gh-pages.yml
2021-02-19 17:51:19 +08:00
xrkffgg
19c073d744 chore: add env & fix link 2021-02-18 10:00:08 +08:00
xrkffgg
a6a35924a4 Create surge-preview.yml 2021-02-18 09:55:37 +08:00
xrkffgg
eb13c18a92 docs: add users 2021-02-13 03:57:37 +08:00
xrkffgg
d4e1fb07d0 chore: remove build env 2021-02-07 11:56:38 +08:00
xrkffgg
d2ccffe750 docs: add users 2021-02-07 11:49:20 +08:00
xrkffgg
f65aeadf97 docs: update labels helper 2021-02-04 11:46:45 +08:00
xrkffgg
03f463ffc8 Delete surge-preview.yml 2021-02-03 22:41:25 +08:00
xrkffgg
728e5aa63e Update ci.yml 2021-02-03 11:03:24 +08:00
xrkffgg
2a7406da4f docs: add rate limit
close https://github.com/actions-cool/issues-helper/issues/56
2021-02-03 09:57:23 +08:00
xrkffgg
f743eedacb chore: add catch (#59)
* chore: add catch

* format
2021-02-03 09:28:14 +08:00
xrkffgg
65461c17ed docs: update v2.1.1 (#58) 2021-02-03 00:45:14 +08:00
xrkffgg
1efbf3d3cf fix: api request limit (#57) 2021-02-03 00:34:17 +08:00
26 changed files with 484 additions and 294 deletions

View File

@@ -17,6 +17,3 @@ jobs:
- name: package - name: package
run: yarn package run: yarn package
- name: package
run: yarn docs:build

View File

@@ -1,14 +1,12 @@
name: 🔂 Surge PR Preview name: 🔂 Surge PR Preview
on: pull_request_target on: pull_request
jobs: jobs:
preview: preview:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- uses: afc163/surge-preview@v1 - uses: afc163/surge-preview@v1
with: with:
surge_token: ${{ secrets.SURGE_TOKEN }} surge_token: ${{ secrets.SURGE_TOKEN }}

View File

@@ -1,3 +1,18 @@
# Changelog
## v2.1.2
`2021.02.19`
- feat: update/delete comment support find-comments out. [#63](https://github.com/actions-cool/issues-helper/pull/63)
## v2.1.1
`2021.02.03`
- fix: api request limit. [#57](https://github.com/actions-cool/issues-helper/pull/57)
- chore: add catch. [#59](https://github.com/actions-cool/issues-helper/pull/59)
## v2.1.0 ## v2.1.0
`2021.02.02` `2021.02.02`

View File

@@ -51,6 +51,11 @@ Please leave a message at [**here**](https://github.com/actions-cool/issues-help
<div>dumi</div> <div>dumi</div>
</a></td> </a></td>
</tr><tr> </tr><tr>
<td align="center" width="180">
<a href="https://github.com/vuejs/jsx-next">
<img src="https://avatars.githubusercontent.com/u/6128107?s=200&v=4" width="46" />
<div>jsx-next</div>
</a></td>
<td align="center" width="180"> <td align="center" width="180">
<a href="https://github.com/mui-org/material-ui"> <a href="https://github.com/mui-org/material-ui">
<img src="https://avatars2.githubusercontent.com/u/33663932?s=200&v=4" width="46" /> <img src="https://avatars2.githubusercontent.com/u/33663932?s=200&v=4" width="46" />
@@ -66,12 +71,12 @@ Please leave a message at [**here**](https://github.com/actions-cool/issues-help
<img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" /> <img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" />
<div>pro-components</div> <div>pro-components</div>
</a></td> </a></td>
</tr><tr>
<td align="center" width="180"> <td align="center" width="180">
<a href="https://github.com/react-component"> <a href="https://github.com/react-component">
<img src="https://avatars3.githubusercontent.com/u/9441414?s=200&v=4" width="46" /> <img src="https://avatars3.githubusercontent.com/u/9441414?s=200&v=4" width="46" />
<div>react-component</div> <div>react-component</div>
</a></td> </a></td>
</tr><tr>
<td align="center" width="180"> <td align="center" width="180">
<a href="https://github.com/lijinke666/react-music-player"> <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" /> <img src="https://github.com/lijinke666/react-music-player/blob/master/assetsImg/logo.png?raw=true" width="46" />
@@ -82,6 +87,12 @@ Please leave a message at [**here**](https://github.com/actions-cool/issues-help
<img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" /> <img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" />
<div>umi</div> <div>umi</div>
</a></td> </a></td>
<td align="center" width="180">
<a href="https://github.com/vitejs/vite">
<img src="https://avatars.githubusercontent.com/u/65625612?s=200&v=4" width="46" />
<div>vite</div>
</a></td>
</tr><tr>
<td align="center" width="180"> <td align="center" width="180">
<a href="https://github.com/AttoJS/vue-request"> <a href="https://github.com/AttoJS/vue-request">
<img src="https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png" width="46" /> <img src="https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png" width="46" />
@@ -92,6 +103,8 @@ Please leave a message at [**here**](https://github.com/actions-cool/issues-help
<img src="https://avatars1.githubusercontent.com/u/70757173?s=200&v=4" width="46" /> <img src="https://avatars1.githubusercontent.com/u/70757173?s=200&v=4" width="46" />
<div>zoo</div> <div>zoo</div>
</a></td> </a></td>
<td align="center" width="180"></td>
<td align="center" width="180"></td>
</tr> </tr>
</table> </table>
@@ -149,7 +162,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Add assigness - name: Add assigness
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'add-assignees' actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -191,7 +204,7 @@ jobs:
if: contains(github.event.issue.body, 'xxx') == false if: contains(github.event.issue.body, 'xxx') == false
steps: steps:
- name: Add labels - name: Add labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'add-labels' actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -216,7 +229,7 @@ Close the specified issue.
```yml ```yml
- name: Close issue - name: Close issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'close-issue' actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -249,7 +262,7 @@ jobs:
if: github.event.label.name == 'xxx' if: github.event.label.name == 'xxx'
steps: steps:
- name: Create comment - name: Create comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-comment' actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -293,7 +306,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create issue - name: Create issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-issue' actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -322,11 +335,11 @@ jobs:
#### `create-label` #### `create-label`
Create labelIf you want to create multiple labels base on repository path. [See](https://github.com/actions-cool/create-labels). Create label. If you want to maintain labels in batches, [see](https://github.com/actions-cool/labels-helper).
```yml ```yml
- name: Create label - name: Create label
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-label' actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -354,7 +367,7 @@ According to [`comment-id`](#comment-id) delete the specified comment.
```yml ```yml
- name: Delete comment - name: Delete comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'delete-comment' actions: 'delete-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -366,6 +379,9 @@ According to [`comment-id`](#comment-id) delete the specified comment.
| actions | Action type | string | ✔ | | actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ | | token | [Token explain](#token) | string | ✔ |
| comment-id | The comment ID | number | ✔ | | comment-id | The comment ID | number | ✔ |
| out-comments | The output of `find-comments`, if you find multiple, operate multiple | string | ✖ |
- When `out-comments` is entered, `comment-id` does not work
⏫ [Back to list](#List) ⏫ [Back to list](#List)
@@ -386,7 +402,7 @@ jobs:
if: github.event.label.name == 'invalid' if: github.event.label.name == 'invalid'
steps: steps:
- name: Lock issue - name: Lock issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'lock-issue' actions: 'lock-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -420,7 +436,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: mark-duplicate - name: mark-duplicate
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'mark-duplicate' actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -455,7 +471,7 @@ Open the specified issue.
```yml ```yml
- name: Open issue - name: Open issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'open-issue' actions: 'open-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -476,7 +492,7 @@ Remove the person designated by issue.
```yml ```yml
- name: Remove assignees - name: Remove assignees
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'remove-assignees' actions: 'remove-assignees'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -499,7 +515,7 @@ Remove the specified labels.
```yml ```yml
- name: Remove labels - name: Remove labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'remove-labels' actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -524,7 +540,7 @@ Replace the labels of issue.
```yml ```yml
- name: Set labels - name: Set labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'set-labels' actions: 'set-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -547,7 +563,7 @@ Unlock the specified issue.
```yml ```yml
- name: Unlock issue - name: Unlock issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'unlock-issue' actions: 'unlock-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -580,7 +596,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Update comment - name: Update comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-comment' actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -593,12 +609,14 @@ jobs:
| actions | Action type | string | ✔ | | actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ | | token | [Token explain](#token) | string | ✔ |
| comment-id | The comment ID | number | ✔ | | comment-id | The comment ID | number | ✔ |
| out-comments | The output of `find-comments`, if you find multiple, operate multiple | string | ✖ |
| body | Update the content of comment | string | ✖ | | body | Update the content of comment | string | ✖ |
| update-mode | Update mode. Default `replace`, another `append` | string | ✖ | | update-mode | Update mode. Default `replace`, another `append` | string | ✖ |
| contents | Add [reaction](#reactions-types) | string | ✖ | | contents | Add [reaction](#reactions-types) | string | ✖ |
- When `body` is not entered, it will remain as it is - When `body` is not entered, it will remain as it is
- When `update-mode` is `append`, additional operations will be performed. Anything other than `append` will be replaced. Only effective for `body` - When `update-mode` is `append`, additional operations will be performed. Anything other than `append` will be replaced. Only effective for `body`
- When `out-comments` is entered, `comment-id` does not work
⏫ [Back to list](#List) ⏫ [Back to list](#List)
@@ -608,7 +626,7 @@ Update the specified issue according to the `issue-number`.
```yml ```yml
- name: Update issue - name: Update issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-issue' actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -658,7 +676,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: welcome - name: welcome
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'welcome' actions: 'welcome'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -701,7 +719,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-inactive - name: check-inactive
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'check-inactive' actions: 'check-inactive'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -754,7 +772,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-issue - name: check-issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'check-issue' actions: 'check-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -793,7 +811,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: close-issues - name: close-issues
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'close-issues' actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -827,7 +845,7 @@ Find the current warehouse issue No. 1, the creator is k and the content contain
```yml ```yml
- name: Find comments - name: Find comments
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'find-comments' actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -875,7 +893,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: lock-issues - name: lock-issues
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'lock-issues' actions: 'lock-issues'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -922,7 +940,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: month-statistics - name: month-statistics
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'month-statistics' actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -950,13 +968,15 @@ Flexible reference.
### `find-comments + create-comment + update-comment` ### `find-comments + create-comment + update-comment`
Hypothetical scenario: When the issue modification of the `watch` label is added, find out whether there is a comment containing `error` created by k, if there is only one, update the comment, if not, add a new comment. Hypothetical scenario: When the issue modification of the `watch` label is added, find out whether there is a comment created by k that contains `<!-- Created by actions-cool/issues-helper -->`, if so, update the comment, If not, add a comment.
Of course, if you need such a scene, you can directly use [**Maintain One Comment**](https://github.com/actions-cool/maintain-one-comment).
```yml ```yml
name: Test name: Test
on: on:
isssue: issues:
types: [edited] types: [edited]
jobs: jobs:
@@ -965,32 +985,40 @@ jobs:
if: github.event.label.name == 'watch' if: github.event.label.name == 'watch'
steps: steps:
- name: find comments - name: find comments
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
id: fcid id: fcid
with: with:
actions: 'find-comments' actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }} issue-number: ${{ github.event.issue.number }}
comment-auth: k comment-auth: k
body-includes: 'error' body-includes: '<!-- Created by actions-cool/issues-helper -->'
# Output view found content. GitHub default outputs are strings
- run: echo find-comments ${{ steps.fcid.outputs.comments }}
shell: bash
- name: create comment - name: create comment
if: ${{ steps.fcid.outputs.comments.length == 0 }} if: contains(steps.fcid.outputs.comments, '<!-- Created by actions-cool/issues-helper -->') == false
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-comment' actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }} issue-number: ${{ github.event.issue.number }}
body: 'Some error!' body: |
Error
<!-- Created by actions-cool/issues-helper -->
- name: update comment - name: update comment
if: ${{ steps.fcid.outputs.comments.length == 1 }} if: contains(steps.fcid.outputs.comments, '<!-- Created by actions-cool/issues-helper -->') == true
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-comment' actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.fcid.outputs.comments[0].id }} out-comments: ${{ steps.fcid.outputs.comments }}
body: 'Some error again!' body: |
Error Again
<!-- Created by actions-cool/issues-helper -->
update-mode: 'append' update-mode: 'append'
``` ```
@@ -1009,7 +1037,14 @@ Need to have the person token with push permission.
- `Name` is the same as in actions - `Name` is the same as in actions
- `Value` fill in the token just applied by the individual - `Value` fill in the token just applied by the individual
When the token is not filled in actions or the corresponding secrets are not added to the project, it will default to github-actions <kbd>bot</kbd>. [More](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow). When the token is not filled in actions or input `${{ secrets.GITHUB_TOKEN }}`, it will default to `github-actions-bot`. [More](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow).
⏫ [Back to list](#List)
### GitHub Docs
- [Workflow syntax for GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
- [Events that trigger workflows](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
⏫ [Back to list](#List) ⏫ [Back to list](#List)
@@ -1017,7 +1052,7 @@ When the token is not filled in actions or the corresponding secrets are not add
```yml ```yml
- name: Create issue - name: Create issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
id: createissue id: createissue
with: with:
actions: 'create-issue' actions: 'create-issue'
@@ -1026,12 +1061,10 @@ When the token is not filled in actions or the corresponding secrets are not add
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}" run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
``` ```
[More](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs). More:
### GitHub Docs 1. https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs
2. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
- [Workflow syntax for GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
- [Events that trigger workflows](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
⏫ [Back to list](#List) ⏫ [Back to list](#List)
@@ -1110,10 +1143,12 @@ Click the `···` icon in the upper right corner of a comment, select `Copy lin
uses: actions-cool/issues-helper@1.x uses: actions-cool/issues-helper@1.x
``` ```
- v2 [upgrade reference](https://github.com/actions-cool/issues-helper/blob/fix/docs/guide/faq.en-US.md#what-should-i-pay-attention-to-when-upgrading-from-v1x-to-v2)
## Actions Template ## Actions Template
- You can directly use this [GitHub Actions workflow template](https://github.com/actions-cool/.github) repositorie template - You can directly use this [GitHub Actions workflow template](https://github.com/actions-cool/.github) repositorie template
- Personal exercises and tests [Actions](https://github.com/xrkffgg/test-ci) repository - Personal exercises and tests [Actions](https://github.com/actions-cool/test-issues-helper) repository
- Can also refer to the warehouse of [online users](#who-is-using) - Can also refer to the warehouse of [online users](#who-is-using)
## ⚡ Feedback ## ⚡ Feedback

123
README.md
View File

@@ -51,6 +51,11 @@
<div>dumi</div> <div>dumi</div>
</a></td> </a></td>
</tr><tr> </tr><tr>
<td align="center" width="180">
<a href="https://github.com/vuejs/jsx-next">
<img src="https://avatars.githubusercontent.com/u/6128107?s=200&v=4" width="46" />
<div>jsx-next</div>
</a></td>
<td align="center" width="180"> <td align="center" width="180">
<a href="https://github.com/mui-org/material-ui"> <a href="https://github.com/mui-org/material-ui">
<img src="https://avatars2.githubusercontent.com/u/33663932?s=200&v=4" width="46" /> <img src="https://avatars2.githubusercontent.com/u/33663932?s=200&v=4" width="46" />
@@ -66,12 +71,12 @@
<img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" /> <img src="https://avatars1.githubusercontent.com/u/12101536?s=200&v=4" width="46" />
<div>pro-components</div> <div>pro-components</div>
</a></td> </a></td>
</tr><tr>
<td align="center" width="180"> <td align="center" width="180">
<a href="https://github.com/react-component"> <a href="https://github.com/react-component">
<img src="https://avatars3.githubusercontent.com/u/9441414?s=200&v=4" width="46" /> <img src="https://avatars3.githubusercontent.com/u/9441414?s=200&v=4" width="46" />
<div>react-component</div> <div>react-component</div>
</a></td> </a></td>
</tr><tr>
<td align="center" width="180"> <td align="center" width="180">
<a href="https://github.com/lijinke666/react-music-player"> <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" /> <img src="https://github.com/lijinke666/react-music-player/blob/master/assetsImg/logo.png?raw=true" width="46" />
@@ -82,6 +87,12 @@
<img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" /> <img src="https://avatars1.githubusercontent.com/u/33895495?s=200&v=4" width="46" />
<div>umi</div> <div>umi</div>
</a></td> </a></td>
<td align="center" width="180">
<a href="https://github.com/vitejs/vite">
<img src="https://avatars.githubusercontent.com/u/65625612?s=200&v=4" width="46" />
<div>vite</div>
</a></td>
</tr><tr>
<td align="center" width="180"> <td align="center" width="180">
<a href="https://github.com/AttoJS/vue-request"> <a href="https://github.com/AttoJS/vue-request">
<img src="https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png" width="46" /> <img src="https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png" width="46" />
@@ -92,6 +103,8 @@
<img src="https://avatars1.githubusercontent.com/u/70757173?s=200&v=4" width="46" /> <img src="https://avatars1.githubusercontent.com/u/70757173?s=200&v=4" width="46" />
<div>zoo</div> <div>zoo</div>
</a></td> </a></td>
<td align="center" width="180"></td>
<td align="center" width="180"></td>
</tr> </tr>
</table> </table>
@@ -149,7 +162,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Add assigness - name: Add assigness
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'add-assignees' actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -191,7 +204,7 @@ jobs:
if: contains(github.event.issue.body, 'xxx') == false if: contains(github.event.issue.body, 'xxx') == false
steps: steps:
- name: Add labels - name: Add labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'add-labels' actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -216,7 +229,7 @@ jobs:
```yml ```yml
- name: Close issue - name: Close issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'close-issue' actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -249,7 +262,7 @@ jobs:
if: github.event.label.name == 'xxx' if: github.event.label.name == 'xxx'
steps: steps:
- name: Create comment - name: Create comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-comment' actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -293,7 +306,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create issue - name: Create issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-issue' actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -322,11 +335,11 @@ jobs:
#### `create-label` #### `create-label`
新增 label。若想根据目录生成多个 labels[可查看](https://github.com/actions-cool/create-labels)。 新增 label。若想批量维护 labels[可查看](https://github.com/actions-cool/labels-helper)。
```yml ```yml
- name: Create label - name: Create label
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-label' actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -354,7 +367,7 @@ jobs:
```yml ```yml
- name: Delete comment - name: Delete comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'delete-comment' actions: 'delete-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -366,6 +379,9 @@ jobs:
| actions | 操作类型 | string | ✔ | | actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ | | token | [token 说明](#token) | string | ✔ |
| comment-id | 指定的 comment | number | ✔ | | comment-id | 指定的 comment | number | ✔ |
| out-comments | `find-comments` 的输出,若查找多个,则操作多个 | string | ✖ |
-`out-comments` 输入时,`comment-id` 不起作用
⏫ [返回列表](#列-表) ⏫ [返回列表](#列-表)
@@ -386,7 +402,7 @@ jobs:
if: github.event.label.name == 'invalid' if: github.event.label.name == 'invalid'
steps: steps:
- name: Lock issue - name: Lock issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'lock-issue' actions: 'lock-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -420,7 +436,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: mark-duplicate - name: mark-duplicate
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'mark-duplicate' actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -455,7 +471,7 @@ jobs:
```yml ```yml
- name: Open issue - name: Open issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'open-issue' actions: 'open-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -476,7 +492,7 @@ jobs:
```yml ```yml
- name: Remove assignees - name: Remove assignees
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'remove-assignees' actions: 'remove-assignees'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -499,7 +515,7 @@ jobs:
```yml ```yml
- name: Remove labels - name: Remove labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'remove-labels' actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -524,7 +540,7 @@ jobs:
```yml ```yml
- name: Set labels - name: Set labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'set-labels' actions: 'set-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -547,7 +563,7 @@ jobs:
```yml ```yml
- name: Unlock issue - name: Unlock issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'unlock-issue' actions: 'unlock-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -580,7 +596,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Update comment - name: Update comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-comment' actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -593,12 +609,14 @@ jobs:
| actions | 操作类型 | string | ✔ | | actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ | | token | [token 说明](#token) | string | ✔ |
| comment-id | 指定的 comment | number | ✔ | | comment-id | 指定的 comment | number | ✔ |
| out-comments | `find-comments` 的输出,若查找多个,则操作多个 | string | ✖ |
| body | 更新 comment 的内容 | string | ✖ | | body | 更新 comment 的内容 | string | ✖ |
| update-mode | 更新模式。默认 `replace` 替换,`append` 附加 | string | ✖ | | update-mode | 更新模式。默认 `replace` 替换,`append` 附加 | string | ✖ |
| contents | 增加 [reaction](#reactions-types) | string | ✖ | | contents | 增加 [reaction](#reactions-types) | string | ✖ |
- `body` 不填时,会保持原有 - `body` 不填时,会保持原有
- `update-mode``append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效 - `update-mode``append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效
-`out-comments` 输入时,`comment-id` 不起作用
⏫ [返回列表](#列-表) ⏫ [返回列表](#列-表)
@@ -608,7 +626,7 @@ jobs:
```yml ```yml
- name: Update issue - name: Update issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-issue' actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -656,7 +674,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: welcome - name: welcome
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'welcome' actions: 'welcome'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -699,7 +717,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-inactive - name: check-inactive
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'check-inactive' actions: 'check-inactive'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -748,7 +766,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-issue - name: check-issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'check-issue' actions: 'check-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -787,7 +805,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: close-issues - name: close-issues
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'close-issues' actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -821,7 +839,7 @@ jobs:
```yml ```yml
- name: Find comments - name: Find comments
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'find-comments' actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -869,7 +887,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: lock-issues - name: lock-issues
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'lock-issues' actions: 'lock-issues'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -916,7 +934,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: month-statistics - name: month-statistics
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'month-statistics' actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -944,13 +962,15 @@ jobs:
### `find-comments + create-comment + update-comment` ### `find-comments + create-comment + update-comment`
假设场景:当添加了 `watch` label 的 issue 修改时,查找是否有 k 创建的包含 `error` 的评论,如果只有一个,则更新 comment如果没有则新增一个 comment。 假设场景:当添加了 `watch` label 的 issue 修改时,查找是否有 k 创建的包含 `<!-- Created by actions-cool/issues-helper -->` 的评论,如果,则更新 comment如果没有则新增一个 comment。
当然,如果你需要这样的场景,可以直接使用 [**Maintain One Comment**](https://github.com/actions-cool/maintain-one-comment)。
```yml ```yml
name: Test name: Test
on: on:
isssue: issues:
types: [edited] types: [edited]
jobs: jobs:
@@ -959,32 +979,40 @@ jobs:
if: github.event.label.name == 'watch' if: github.event.label.name == 'watch'
steps: steps:
- name: find comments - name: find comments
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
id: fcid id: fcid
with: with:
actions: 'find-comments' actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }} issue-number: ${{ github.event.issue.number }}
comment-auth: k comment-auth: k
body-includes: 'error' body-includes: '<!-- Created by actions-cool/issues-helper -->'
# 输出查看找到的内容。GitHub 默认 outputs 为字符串
- run: echo find-comments ${{ steps.fcid.outputs.comments }}
shell: bash
- name: create comment - name: create comment
if: ${{ steps.fcid.outputs.comments.length == 0 }} if: contains(steps.fcid.outputs.comments, '<!-- Created by actions-cool/issues-helper -->') == false
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-comment' actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }} issue-number: ${{ github.event.issue.number }}
body: 'Some error!' body: |
Error
<!-- Created by actions-cool/issues-helper -->
- name: update comment - name: update comment
if: ${{ steps.fcid.outputs.comments.length == 1 }} if: contains(steps.fcid.outputs.comments, '<!-- Created by actions-cool/issues-helper -->') == true
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-comment' actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.fcid.outputs.comments[0].id }} out-comments: ${{ steps.fcid.outputs.comments }}
body: 'Some error again!' body: |
Error Again
<!-- Created by actions-cool/issues-helper -->
update-mode: 'append' update-mode: 'append'
``` ```
@@ -1003,7 +1031,14 @@ jobs:
- `Name` 与 actions 中保持一致 - `Name` 与 actions 中保持一致
- `Value` 填写刚才个人申请的 token - `Value` 填写刚才个人申请的 token
当 actions 不填写 token 时,或项目未添加对应 secrets 时,会默认为 github-actions <kbd>bot</kbd>。[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)。 当 actions 不填写 token 时,或填写 `${{ secrets.GITHUB_TOKEN }}`,会默认为 `github-actions-bot`。[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)。
⏫ [返回列表](#列-表)
### GitHub Docs
- [GitHub Actions 语法](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
- [工作流触发机制](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
⏫ [返回列表](#列-表) ⏫ [返回列表](#列-表)
@@ -1011,7 +1046,7 @@ jobs:
```yml ```yml
- name: Create issue - name: Create issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
id: createissue id: createissue
with: with:
actions: 'create-issue' actions: 'create-issue'
@@ -1020,12 +1055,10 @@ jobs:
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}" run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
``` ```
[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs)。 更多查看
### GitHub Docs 1. https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs
2. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
- [GitHub Actions 语法](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
- [工作流触发机制](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
⏫ [返回列表](#列-表) ⏫ [返回列表](#列-表)
@@ -1105,10 +1138,12 @@ x2 + y2
uses: actions-cool/issues-helper@1.x uses: actions-cool/issues-helper@1.x
``` ```
- v2 [升级参考](https://github.com/actions-cool/issues-helper/blob/fix/docs/guide/faq.md#%E4%BB%8E-v1x-%E5%8D%87%E7%BA%A7%E5%88%B0-v2%E6%9C%89%E4%BB%80%E4%B9%88%E6%B3%A8%E6%84%8F%E7%9A%84%E5%9C%B0%E6%96%B9%E5%90%97)
## Actions 模板 ## Actions 模板
- 可直接使用这个 [GitHub Actions workflow template](https://github.com/actions-cool/.github) 仓库的模板 - 可直接使用这个 [GitHub Actions workflow template](https://github.com/actions-cool/.github) 仓库的模板
- 个人练习和测试 [Actions](https://github.com/xrkffgg/test-ci) 的仓库 - 个人练习和测试 [Actions](https://github.com/actions-cool/test-issues-helper) 的仓库
- 也可以来 [线上使用者](#谁在使用) 的仓库参照 - 也可以来 [线上使用者](#谁在使用) 的仓库参照
## ⚡ 反馈 ## ⚡ 反馈

View File

@@ -49,6 +49,14 @@ const users = [
url: 'https://github.com/prettier/prettier', url: 'https://github.com/prettier/prettier',
logo: 'https://github.com/prettier/prettier-logo/blob/master/images/prettier-icon-light.png?raw=true' logo: 'https://github.com/prettier/prettier-logo/blob/master/images/prettier-icon-light.png?raw=true'
}, },
{
url: 'https://github.com/vuejs/jsx-next',
logo: 'https://avatars.githubusercontent.com/u/6128107?s=200&v=4'
},
{
url: 'https://github.com/vitejs/vite',
logo: 'https://avatars.githubusercontent.com/u/65625612?s=200&v=4'
},
]; ];
// ************************************************************************** // **************************************************************************

View File

@@ -40,8 +40,12 @@ inputs:
description: 'Issue reactions emoji' description: 'Issue reactions emoji'
direction: direction:
description: 'Find comments direction' description: 'Find comments direction'
# comments
comment-auth: comment-auth:
description: 'Find comments query auth' description: 'Find comments query auth'
out-comments:
description: 'Find comments out comments'
assignee-includes: assignee-includes:
description: 'Check use' description: 'Check use'
body-includes: body-includes:

175
dist/index.js vendored
View File

@@ -7705,6 +7705,7 @@ async function doFindComments(owner, repo, issueNumber) {
} }
}); });
core.setOutput('comments', comments); core.setOutput('comments', comments);
core.info(`out-comments: ${JSON.stringify(comments)}`);
} }
async function doLockIssues(owner, repo, labels) { async function doLockIssues(owner, repo, labels) {
@@ -8005,17 +8006,32 @@ async function doCreateLabel(owner, repo) {
}); });
core.info(`Actions: [create-label][${name}] success!`); core.info(`Actions: [create-label][${name}] success!`);
} catch (err) { } catch (err) {
console.log(err.message) console.log(err.message);
} }
} }
async function doDeleteComment(owner, repo, commentId) { async function doDeleteComment(owner, repo, commentId) {
await octokit.issues.deleteComment({ let id = commentId;
owner,
repo, const outComments = core.getInput('out-comments');
comment_id: commentId, if (outComments) {
}); const outCommentsArr = JSON.parse(outComments);
core.info(`Actions: [delete-comment][${commentId}] success!`); core.info(`Actions: [out-comments-length][${outCommentsArr.length}] success!`);
outCommentsArr.forEach(async item => {
await doDelet(item.id);
});
} else {
await doDelet(id);
}
async function doDelet(id) {
await octokit.issues.deleteComment({
owner,
repo,
comment_id: id,
});
core.info(`Actions: [delete-comment][${id}] success!`);
}
} }
async function doLockIssue(owner, repo, issueNumber) { async function doLockIssue(owner, repo, issueNumber) {
@@ -8053,17 +8069,6 @@ async function doMarkDuplicate(owner, repo, labels) {
const ifCommandInput = !!duplicateCommand; const ifCommandInput = !!duplicateCommand;
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
if ( if (
!commentBody.includes('?') && !commentBody.includes('?') &&
((ifCommandInput && ((ifCommandInput &&
@@ -8071,37 +8076,52 @@ async function doMarkDuplicate(owner, repo, labels) {
commentBody.split(' ')[0] == duplicateCommand) || commentBody.split(' ')[0] == duplicateCommand) ||
testDuplicate(commentBody)) testDuplicate(commentBody))
) { ) {
if (ifCommandInput) { try {
const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); const res = await octokit.repos.getCollaboratorPermissionLevel({
await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true); owner,
} else if (contents) { repo,
await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents)); username: commentUser,
} });
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
const issue = await octokit.issues.get({ if (ifCommandInput) {
owner, const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of');
repo, await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);
issue_number: issueNumber, } else if (contents) {
}); await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents));
let newLabels = []; }
if (issue.data.labels.length > 0) {
newLabels = issue.data.labels
.map(({ name }) => name)
.filter(name => !dealStringToArr(removeLables).includes(name));
}
if (duplicateLabels) {
newLabels = [...newLabels, ...dealStringToArr(duplicateLabels)];
}
if (labels) {
newLabels = dealStringToArr(labels);
}
if (newLabels.length > 0) {
await doSetLabels(owner, repo, issueNumber, newLabels.toString());
core.info(`Actions: [mark-duplicate-labels][${newLabels}] success!`);
}
if (closeIssue == 'true') { const issue = await octokit.issues.get({
await doCloseIssue(owner, repo, issueNumber); owner,
repo,
issue_number: issueNumber,
});
let newLabels = [];
if (issue.data.labels.length > 0) {
newLabels = issue.data.labels
.map(({ name }) => name)
.filter(name => !dealStringToArr(removeLables).includes(name));
}
if (duplicateLabels) {
newLabels = [...newLabels, ...dealStringToArr(duplicateLabels)];
}
if (labels) {
newLabels = dealStringToArr(labels);
}
if (newLabels.length > 0) {
await doSetLabels(owner, repo, issueNumber, newLabels.toString());
core.info(`Actions: [mark-duplicate-labels][${newLabels}] success!`);
}
if (closeIssue == 'true') {
await doCloseIssue(owner, repo, issueNumber);
}
} catch (error) {
core.info(error.message);
} }
} else { } else {
core.info( core.info(
@@ -8189,32 +8209,47 @@ async function doUnlockIssue(owner, repo, issueNumber) {
} }
async function doUpdateComment(owner, repo, commentId, body, updateMode, ifUpdateBody) { async function doUpdateComment(owner, repo, commentId, body, updateMode, ifUpdateBody) {
const comment = await octokit.issues.getComment({ let id = commentId;
owner,
repo,
comment_id: commentId,
});
const comment_body = comment.data.body;
let params = { const outComments = core.getInput('out-comments');
owner, if (outComments) {
repo, const outCommentsArr = JSON.parse(outComments);
comment_id: commentId, core.info(`Actions: [out-comments-length][${outCommentsArr.length}] success!`);
}; outCommentsArr.forEach(async item => {
await doComment(item.id);
if (core.getInput('body') || ifUpdateBody) { });
if (updateMode === 'append') { } else {
params.body = `${comment_body}\n${body}`; await doComment(id);
} else {
params.body = body;
}
await octokit.issues.updateComment(params);
core.info(`Actions: [update-comment][${commentId}] success!`);
} }
if (contents) { async function doComment(id) {
await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents)); const comment = await octokit.issues.getComment({
owner,
repo,
comment_id: id,
});
const comment_body = comment.data.body;
let params = {
owner,
repo,
comment_id: id,
};
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][${id}] success!`);
}
if (contents) {
await doCreateCommentContent(owner, repo, id, dealStringToArr(contents));
}
} }
} }

View File

@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-inactive - name: check-inactive
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'check-inactive' actions: 'check-inactive'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-issue - name: check-issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'check-issue' actions: 'check-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -110,7 +110,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: close-issues - name: close-issues
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'close-issues' actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -142,7 +142,7 @@ Find the current warehouse issue No. 1, the creator is k and the content contain
```yml ```yml
- name: Find comments - name: Find comments
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'find-comments' actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -188,7 +188,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: lock-issues - name: lock-issues
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'lock-issues' actions: 'lock-issues'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -233,7 +233,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: month-statistics - name: month-statistics
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'month-statistics' actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-inactive - name: check-inactive
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'check-inactive' actions: 'check-inactive'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -69,7 +69,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-issue - name: check-issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'check-issue' actions: 'check-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -106,7 +106,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: close-issues - name: close-issues
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'close-issues' actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -138,7 +138,7 @@ jobs:
```yml ```yml
- name: Find comments - name: Find comments
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'find-comments' actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -184,7 +184,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: lock-issues - name: lock-issues
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'lock-issues' actions: 'lock-issues'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -229,7 +229,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: month-statistics - name: month-statistics
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'month-statistics' actions: 'month-statistics'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Add assigness - name: Add assigness
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'add-assignees' actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -62,7 +62,7 @@ jobs:
if: contains(github.event.issue.body, 'xxx') == false if: contains(github.event.issue.body, 'xxx') == false
steps: steps:
- name: Add labels - name: Add labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'add-labels' actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -85,7 +85,7 @@ Close the specified issue.
```yml ```yml
- name: Close issue - name: Close issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'close-issue' actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -116,7 +116,7 @@ jobs:
if: github.event.label.name == 'xxx' if: github.event.label.name == 'xxx'
steps: steps:
- name: Create comment - name: Create comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-comment' actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -158,7 +158,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create issue - name: Create issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-issue' actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -185,11 +185,11 @@ jobs:
## `create-label` ## `create-label`
Create labelIf you want to create multiple labels base on repository path. [See](https://github.com/actions-cool/create-labels). Create label. If you want to maintain labels in batches, [see](https://github.com/actions-cool/labels-helper).
```yml ```yml
- name: Create label - name: Create label
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-label' actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -215,7 +215,7 @@ According to [`comment-id`](/en-US/guide/ref#-comment-id) delete the specified c
```yml ```yml
- name: Delete comment - name: Delete comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'delete-comment' actions: 'delete-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -227,6 +227,9 @@ According to [`comment-id`](/en-US/guide/ref#-comment-id) delete the specified c
| actions | Action type | string | ✔ | | actions | Action type | string | ✔ |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | | token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| comment-id | The comment ID | number | ✔ | | comment-id | The comment ID | number | ✔ |
| out-comments | The output of `find-comments`, if you find multiple, operate multiple | string | ✖ |
- When `out-comments` is entered, `comment-id` does not work
## `lock-issue` ## `lock-issue`
@@ -245,7 +248,7 @@ jobs:
if: github.event.label.name == 'invalid' if: github.event.label.name == 'invalid'
steps: steps:
- name: Lock issue - name: Lock issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'lock-issue' actions: 'lock-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -277,7 +280,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: mark-duplicate - name: mark-duplicate
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'mark-duplicate' actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -316,7 +319,7 @@ Open the specified issue.
```yml ```yml
- name: Open issue - name: Open issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'open-issue' actions: 'open-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -335,7 +338,7 @@ Remove the person designated by issue.
```yml ```yml
- name: Remove assignees - name: Remove assignees
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'remove-assignees' actions: 'remove-assignees'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -356,7 +359,7 @@ Remove the specified labels.
```yml ```yml
- name: Remove labels - name: Remove labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'remove-labels' actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -379,7 +382,7 @@ Replace the labels of issue.
```yml ```yml
- name: Set labels - name: Set labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'set-labels' actions: 'set-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -400,7 +403,7 @@ Unlock the specified issue.
```yml ```yml
- name: Unlock issue - name: Unlock issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'unlock-issue' actions: 'unlock-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -431,7 +434,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Update comment - name: Update comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-comment' actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -444,12 +447,14 @@ jobs:
| actions | Action type | string | ✔ | | actions | Action type | string | ✔ |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | | token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| comment-id | The comment ID | number | ✔ | | comment-id | The comment ID | number | ✔ |
| out-comments | The output of `find-comments`, if you find multiple, operate multiple | string | ✖ |
| body | Update the content of comment | string | ✖ | | body | Update the content of comment | string | ✖ |
| update-mode | Update mode. Default `replace`, another `append` | string | ✖ | | update-mode | Update mode. Default `replace`, another `append` | string | ✖ |
| contents | Add [reaction](/en-US/guide/ref#-reactions-type) | string | ✖ | | contents | Add [reaction](/en-US/guide/ref#-reactions-type) | string | ✖ |
- When `body` is not entered, it will remain as it is - When `body` is not entered, it will remain as it is
- When `update-mode` is `append`, additional operations will be performed. Anything other than `append` will be replaced. Only effective for `body` - When `update-mode` is `append`, additional operations will be performed. Anything other than `append` will be replaced. Only effective for `body`
- When `out-comments` is entered, `comment-id` does not work
## `update-issue` ## `update-issue`
@@ -457,7 +462,7 @@ Update the specified issue according to the `issue-number`.
```yml ```yml
- name: Update issue - name: Update issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-issue' actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -505,7 +510,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: welcome - name: welcome
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'welcome' actions: 'welcome'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Add assigness - name: Add assigness
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'add-assignees' actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -62,7 +62,7 @@ jobs:
if: contains(github.event.issue.body, 'xxx') == false if: contains(github.event.issue.body, 'xxx') == false
steps: steps:
- name: Add labels - name: Add labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'add-labels' actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -85,7 +85,7 @@ jobs:
```yml ```yml
- name: Close issue - name: Close issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'close-issue' actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -116,7 +116,7 @@ jobs:
if: github.event.label.name == 'xxx' if: github.event.label.name == 'xxx'
steps: steps:
- name: Create comment - name: Create comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-comment' actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -158,7 +158,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create issue - name: Create issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-issue' actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -185,11 +185,11 @@ jobs:
## `create-label` ## `create-label`
新增 label。若想根据目录生成多个 labels[可查看](https://github.com/actions-cool/create-labels)。 新增 label。若想批量维护 labels[可查看](https://github.com/actions-cool/labels-helper)。
```yml ```yml
- name: Create label - name: Create label
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-label' actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -215,7 +215,7 @@ jobs:
```yml ```yml
- name: Delete comment - name: Delete comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'delete-comment' actions: 'delete-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -227,6 +227,9 @@ jobs:
| actions | 操作类型 | string | ✔ | | actions | 操作类型 | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ | | token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| comment-id | 指定的 comment | number | ✔ | | comment-id | 指定的 comment | number | ✔ |
| out-comments | `find-comments` 的输出,若查找多个,则操作多个 | string | ✖ |
-`out-comments` 输入时,`comment-id` 不起作用
## `lock-issue` ## `lock-issue`
@@ -245,7 +248,7 @@ jobs:
if: github.event.label.name == 'invalid' if: github.event.label.name == 'invalid'
steps: steps:
- name: Lock issue - name: Lock issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'lock-issue' actions: 'lock-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -277,7 +280,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: mark-duplicate - name: mark-duplicate
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'mark-duplicate' actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -316,7 +319,7 @@ jobs:
```yml ```yml
- name: Open issue - name: Open issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'open-issue' actions: 'open-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -335,7 +338,7 @@ jobs:
```yml ```yml
- name: Remove assignees - name: Remove assignees
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'remove-assignees' actions: 'remove-assignees'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -356,7 +359,7 @@ jobs:
```yml ```yml
- name: Remove labels - name: Remove labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'remove-labels' actions: 'remove-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -379,7 +382,7 @@ jobs:
```yml ```yml
- name: Set labels - name: Set labels
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'set-labels' actions: 'set-labels'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -400,7 +403,7 @@ jobs:
```yml ```yml
- name: Unlock issue - name: Unlock issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'unlock-issue' actions: 'unlock-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -431,7 +434,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Update comment - name: Update comment
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-comment' actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -444,12 +447,14 @@ jobs:
| actions | 操作类型 | string | ✔ | | actions | 操作类型 | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ | | token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| comment-id | 指定的 comment | number | ✔ | | comment-id | 指定的 comment | number | ✔ |
| out-comments | `find-comments` 的输出,若查找多个,则操作多个 | string | ✖ |
| body | 更新 comment 的内容 | string | ✖ | | body | 更新 comment 的内容 | string | ✖ |
| update-mode | 更新模式。默认 `replace` 替换,`append` 附加 | string | ✖ | | update-mode | 更新模式。默认 `replace` 替换,`append` 附加 | string | ✖ |
| contents | 增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ | | contents | 增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ |
- `body` 不填时,会保持原有 - `body` 不填时,会保持原有
- `update-mode``append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效 - `update-mode``append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效
-`out-comments` 输入时,`comment-id` 不起作用
## `update-issue` ## `update-issue`
@@ -457,7 +462,7 @@ jobs:
```yml ```yml
- name: Update issue - name: Update issue
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'update-issue' actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -504,7 +509,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: welcome - name: welcome
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'welcome' actions: 'welcome'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -27,4 +27,6 @@ toc: menu
uses: actions-cool/issues-helper@1.x uses: actions-cool/issues-helper@1.x
``` ```
- v2 [upgrade reference](/en-US/guide/faq)
<embed src="../CHANGELOG.md"></embed> <embed src="../CHANGELOG.md"></embed>

View File

@@ -27,4 +27,6 @@ toc: menu
uses: actions-cool/issues-helper@1.x uses: actions-cool/issues-helper@1.x
``` ```
- v2 [升级参考](/guide/faq)
<embed src="../CHANGELOG.md"></embed> <embed src="../CHANGELOG.md"></embed>

View File

@@ -6,12 +6,16 @@ toc: menu
GitHub Actions is provided free of charge by GitHub. Among them, the `Private` project has a monthly limit of 2000 times, [see details](https://github.com/settings/billing). The `Public` project is unlimited. GitHub Actions is provided free of charge by GitHub. Among them, the `Private` project has a monthly limit of 2000 times, [see details](https://github.com/settings/billing). The `Public` project is unlimited.
### Is there a rate limit?
Yes. The bottom layer of Action uses GitHub REST API. The general situation is 5000 times per hour. It is basically sufficient in principle, and it is also required to avoid invalid requests when defining Action. [Detailed view](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting).
## Are there any ready-made templates for reference? ## Are there any ready-made templates for reference?
Yes. Yes.
1. You can use this [GitHub Actions workflow template](https://github.com/actions-cool/.github) repository template 1. You can use this [GitHub Actions workflow template](https://github.com/actions-cool/.github) repository template
2. Personal exercises and tests [Actions](https://github.com/xrkffgg/test-ci) repository 2. Personal exercises and tests [Actions](https://github.com/actions-cool/test-issues-helper) repository
3. You can also refer to the warehouse of [online users](/en-US#-who-is-using) 3. You can also refer to the warehouse of [online users](/en-US#-who-is-using)
## I want to pause Actions, is there an easy way? ## I want to pause Actions, is there an easy way?

View File

@@ -6,12 +6,16 @@ toc: menu
GitHub Actions 是由 GitHub 免费提供的。其中 `Private` 项目每月有 2000 次的限制,[具体查看](https://github.com/settings/billing)。`Public` 项目无限制。 GitHub Actions 是由 GitHub 免费提供的。其中 `Private` 项目每月有 2000 次的限制,[具体查看](https://github.com/settings/billing)。`Public` 项目无限制。
### 有没有速率的限制?
有的。Action 底层使用的是 GitHub REST API。一般情况是每小时 5000 次。原则上基本是够用的,同时也要求在 Action 定义时,尽量避免无效的请求。[具体查看](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting)。
## 有没有现成的模板可以参考? ## 有没有现成的模板可以参考?
有的。 有的。
1. 你可以使用这个 [GitHub Actions workflow template](https://github.com/actions-cool/.github) 仓库的模板 1. 你可以使用这个 [GitHub Actions workflow template](https://github.com/actions-cool/.github) 仓库的模板
2. 个人练习和测试 [Actions](https://github.com/xrkffgg/test-ci) 的仓库 2. 个人练习和测试 [Actions](https://github.com/actions-cool/test-issues-helper) 的仓库
3. 也可以来 [线上使用者](/#-谁在使用?) 的仓库参照 3. 也可以来 [线上使用者](/#-谁在使用?) 的仓库参照
## 我想暂停 Actions有没有简单的办法 ## 我想暂停 Actions有没有简单的办法

View File

@@ -28,7 +28,7 @@ with:
- `count-lables`: Regardless of setting `true` or `'ture'`, all received in the program is in string format - `count-lables`: Regardless of setting `true` or `'ture'`, all received in the program is in string format
At the same time, the output is also in string format At the same time, the output is also in string format. [See](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs).
- `check-result`: The judgment condition is `if: steps.xxid.outputs.check-result =='true'` - `check-result`: The judgment condition is `if: steps.xxid.outputs.check-result =='true'`

View File

@@ -29,7 +29,7 @@ with:
- `count-lables`:不管设置 `true` 还是 `'ture'`,在程序里接收到的都是字符串格式 - `count-lables`:不管设置 `true` 还是 `'ture'`,在程序里接收到的都是字符串格式
同时输出的也是字符串格式 同时输出的也是字符串格式。[参看](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs)。
- `check-result`:判断条件为 `if: steps.xxid.outputs.check-result == 'true'` - `check-result`:判断条件为 `if: steps.xxid.outputs.check-result == 'true'`

View File

@@ -13,7 +13,7 @@ Need to have the person token with push permission.
- `Name` is the same as in actions - `Name` is the same as in actions
- `Value` fill in the token just applied by the individual - `Value` fill in the token just applied by the individual
When the token is not filled in actions or the corresponding secrets are not added to the project, it will default to `github-actions-bot`. [More](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow). When the token is not filled in actions or input `${{ secrets.GITHUB_TOKEN }}`, it will default to `github-actions-bot`. [More](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow).
## 📍 GitHub Docs ## 📍 GitHub Docs
@@ -33,7 +33,10 @@ When the token is not filled in actions or the corresponding secrets are not add
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}" run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
``` ```
[More](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs). More:
1. https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs
2. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
## 📍 `includes` check rules ## 📍 `includes` check rules

View File

@@ -13,7 +13,7 @@ toc: menu
- `Name` 与 actions 中保持一致 - `Name` 与 actions 中保持一致
- `Value` 填写刚才个人申请的 token - `Value` 填写刚才个人申请的 token
当 actions 不填写 token 时,或项目未添加对应 secrets 时,会默认为 `github-actions-bot`。[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)。 当 actions 不填写 token 时,或输入 `${{ secrets.GITHUB_TOKEN }}`,会默认为 `github-actions-bot`。[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)。
## 📍 GitHub 相关文档 ## 📍 GitHub 相关文档
@@ -33,7 +33,10 @@ toc: menu
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}" run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
``` ```
[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs)。 更多查看
1. https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs
2. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
## 📍 `includes` 校验规则 ## 📍 `includes` 校验规则

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: help wanted - name: help wanted
if: github.event.label.name == 'help wanted' if: github.event.label.name == 'help wanted'
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-comment' actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: help wanted - name: help wanted
if: github.event.label.name == 'help wanted' if: github.event.label.name == 'help wanted'
uses: actions-cool/issues-helper@v2.1.0 uses: actions-cool/issues-helper@v2.1.2
with: with:
actions: 'create-comment' actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,6 +1,6 @@
{ {
"name": "issues-helper", "name": "issues-helper",
"version": "2.0.0", "version": "2.1.2",
"private": true, "private": true,
"description": "Some operations on issue.", "description": "Some operations on issue.",
"main": "src/main.js", "main": "src/main.js",

View File

@@ -1,7 +1,7 @@
const { readFileSync, writeFileSync } = require('fs'); const { readFileSync, writeFileSync } = require('fs');
const last = /v2\.0\.0/g; const last = /v2\.1\.1/g;
const now = 'v2.1.0'; const now = 'v2.1.2';
let readme = readFileSync('./README.md', 'utf-8'); let readme = readFileSync('./README.md', 'utf-8');
readme = readme.replace(last, now); readme = readme.replace(last, now);

View File

@@ -147,6 +147,7 @@ async function doFindComments(owner, repo, issueNumber) {
} }
}); });
core.setOutput('comments', comments); core.setOutput('comments', comments);
core.info(`out-comments: ${JSON.stringify(comments)}`);
} }
async function doLockIssues(owner, repo, labels) { async function doLockIssues(owner, repo, labels) {

View File

@@ -147,12 +147,27 @@ async function doCreateLabel(owner, repo) {
} }
async function doDeleteComment(owner, repo, commentId) { async function doDeleteComment(owner, repo, commentId) {
await octokit.issues.deleteComment({ let id = commentId;
owner,
repo, const outComments = core.getInput('out-comments');
comment_id: commentId, if (outComments) {
}); const outCommentsArr = JSON.parse(outComments);
core.info(`Actions: [delete-comment][${commentId}] success!`); core.info(`Actions: [out-comments-length][${outCommentsArr.length}] success!`);
outCommentsArr.forEach(async item => {
await doDelet(item.id);
});
} else {
await doDelet(id);
}
async function doDelet(id) {
await octokit.issues.deleteComment({
owner,
repo,
comment_id: id,
});
core.info(`Actions: [delete-comment][${id}] success!`);
}
} }
async function doLockIssue(owner, repo, issueNumber) { async function doLockIssue(owner, repo, issueNumber) {
@@ -190,17 +205,6 @@ async function doMarkDuplicate(owner, repo, labels) {
const ifCommandInput = !!duplicateCommand; const ifCommandInput = !!duplicateCommand;
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
if ( if (
!commentBody.includes('?') && !commentBody.includes('?') &&
((ifCommandInput && ((ifCommandInput &&
@@ -208,37 +212,52 @@ async function doMarkDuplicate(owner, repo, labels) {
commentBody.split(' ')[0] == duplicateCommand) || commentBody.split(' ')[0] == duplicateCommand) ||
testDuplicate(commentBody)) testDuplicate(commentBody))
) { ) {
if (ifCommandInput) { try {
const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); const res = await octokit.repos.getCollaboratorPermissionLevel({
await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true); owner,
} else if (contents) { repo,
await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents)); username: commentUser,
} });
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
const issue = await octokit.issues.get({ if (ifCommandInput) {
owner, const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of');
repo, await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);
issue_number: issueNumber, } else if (contents) {
}); await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents));
let newLabels = []; }
if (issue.data.labels.length > 0) {
newLabels = issue.data.labels
.map(({ name }) => name)
.filter(name => !dealStringToArr(removeLables).includes(name));
}
if (duplicateLabels) {
newLabels = [...newLabels, ...dealStringToArr(duplicateLabels)];
}
if (labels) {
newLabels = dealStringToArr(labels);
}
if (newLabels.length > 0) {
await doSetLabels(owner, repo, issueNumber, newLabels.toString());
core.info(`Actions: [mark-duplicate-labels][${newLabels}] success!`);
}
if (closeIssue == 'true') { const issue = await octokit.issues.get({
await doCloseIssue(owner, repo, issueNumber); owner,
repo,
issue_number: issueNumber,
});
let newLabels = [];
if (issue.data.labels.length > 0) {
newLabels = issue.data.labels
.map(({ name }) => name)
.filter(name => !dealStringToArr(removeLables).includes(name));
}
if (duplicateLabels) {
newLabels = [...newLabels, ...dealStringToArr(duplicateLabels)];
}
if (labels) {
newLabels = dealStringToArr(labels);
}
if (newLabels.length > 0) {
await doSetLabels(owner, repo, issueNumber, newLabels.toString());
core.info(`Actions: [mark-duplicate-labels][${newLabels}] success!`);
}
if (closeIssue == 'true') {
await doCloseIssue(owner, repo, issueNumber);
}
} catch (error) {
core.info(error.message);
} }
} else { } else {
core.info( core.info(
@@ -326,32 +345,47 @@ async function doUnlockIssue(owner, repo, issueNumber) {
} }
async function doUpdateComment(owner, repo, commentId, body, updateMode, ifUpdateBody) { async function doUpdateComment(owner, repo, commentId, body, updateMode, ifUpdateBody) {
const comment = await octokit.issues.getComment({ let id = commentId;
owner,
repo,
comment_id: commentId,
});
const comment_body = comment.data.body;
let params = { const outComments = core.getInput('out-comments');
owner, if (outComments) {
repo, const outCommentsArr = JSON.parse(outComments);
comment_id: commentId, core.info(`Actions: [out-comments-length][${outCommentsArr.length}] success!`);
}; outCommentsArr.forEach(async item => {
await doComment(item.id);
if (core.getInput('body') || ifUpdateBody) { });
if (updateMode === 'append') { } else {
params.body = `${comment_body}\n${body}`; await doComment(id);
} else {
params.body = body;
}
await octokit.issues.updateComment(params);
core.info(`Actions: [update-comment][${commentId}] success!`);
} }
if (contents) { async function doComment(id) {
await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents)); const comment = await octokit.issues.getComment({
owner,
repo,
comment_id: id,
});
const comment_body = comment.data.body;
let params = {
owner,
repo,
comment_id: id,
};
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][${id}] success!`);
}
if (contents) {
await doCreateCommentContent(owner, repo, id, dealStringToArr(contents));
}
} }
} }