mirror of
https://github.com/iv-org/close-potential-duplicates.git
synced 2024-11-22 21:39:40 +00:00
add ability to automatically close the issue
This commit is contained in:
parent
34fe38ec33
commit
9b0c29f521
17
.github/workflows/release.yml
vendored
17
.github/workflows/release.yml
vendored
@ -18,18 +18,9 @@ jobs:
|
||||
run: yarn install
|
||||
|
||||
- name: 📦 Build
|
||||
run: yarn build
|
||||
|
||||
- name: 🔑 Generate Token
|
||||
uses: wow-actions/use-app-token@v1
|
||||
with:
|
||||
app_id: ${{ secrets.APP_ID }}
|
||||
private_key: ${{ secrets.PRIVATE_KEY }}
|
||||
env_name: bot_token
|
||||
run: NODE_OPTIONS=--openssl-legacy-provider yarn build
|
||||
|
||||
- name: 📦 Release
|
||||
uses: wow-actions/release-github-action@v1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ env.bot_token }}
|
||||
GIT_COMMITTER_NAME: wow-actions-bot
|
||||
GIT_COMMITTER_EMAIL: wow-actions-bot@users.noreply.github.com
|
||||
uses: wow-actions/release-github-action@v2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
|
||||
|
21
README.md
21
README.md
@ -1,25 +1,23 @@
|
||||
<h1 align="center">Potential Duplicates</h1>
|
||||
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/wow-actions/potential-duplicates/actions/workflows/release.yml"><img alt="build" src="https://img.shields.io/github/actions/workflow/status/wow-actions/potential-duplicates/release.yml?branch=master&logo=github&style=flat-square" ></a>
|
||||
<a href="/wow-actions/potential-duplicates/blob/master/LICENSE"><img alt="MIT License" src="https://img.shields.io/github/license/wow-actions/potential-duplicates?style=flat-square"></a>
|
||||
<a href="https://github.com/iv-org/close-potential-duplicates/actions/workflows/release.yml"><img alt="build" src="https://img.shields.io/github/actions/workflow/status/iv-org/close-potential-duplicates/release.yml?branch=master&logo=github&style=flat-square" ></a>
|
||||
<a href="/iv-org/close-potential-duplicates/blob/master/LICENSE"><img alt="MIT License" src="https://img.shields.io/github/license/iv-org/close-potential-duplicates?style=flat-square"></a>
|
||||
<a href="https://www.typescriptlang.org" rel="nofollow"><img alt="Language" src="https://img.shields.io/badge/language-TypeScript-blue.svg?style=flat-square"></a>
|
||||
<a href="https://github.com/wow-actions/potential-duplicates/pulls"><img alt="PRs Welcome" src="https://img.shields.io/badge/PRs-Welcome-brightgreen.svg?style=flat-square" ></a>
|
||||
<a href="https://github.com/marketplace/actions/potential-duplicates" rel="nofollow"><img alt="website" src="https://img.shields.io/static/v1?label=&labelColor=505050&message=Marketplace&color=0076D6&style=flat-square&logo=google-chrome&logoColor=0076D6" ></a>
|
||||
<a href="https://lgtm.com/projects/g/wow-actions/potential-duplicates/context:javascript" rel="nofollow"><img alt="Language grade: JavaScript" src="https://img.shields.io/lgtm/grade/javascript/g/wow-actions/potential-duplicates.svg?logo=lgtm&style=flat-square" ></a>
|
||||
<a href="https://github.com/iv-org/close-potential-duplicates/pulls"><img alt="PRs Welcome" src="https://img.shields.io/badge/PRs-Welcome-brightgreen.svg?style=flat-square" ></a>
|
||||
<a href="https://github.com/marketplace/actions/close-potential-duplicates" rel="nofollow"><img alt="website" src="https://img.shields.io/static/v1?label=&labelColor=505050&message=Marketplace&color=0076D6&style=flat-square&logo=google-chrome&logoColor=0076D6" ></a>
|
||||
<a href="https://lgtm.com/projects/g/iv-org/close-potential-duplicates/context:javascript" rel="nofollow"><img alt="Language grade: JavaScript" src="https://img.shields.io/lgtm/grade/javascript/g/iv-org/close-potential-duplicates.svg?logo=lgtm&style=flat-square" ></a>
|
||||
</p>
|
||||
|
||||
|
||||
<p align="center">
|
||||
<strong>
|
||||
Search for potential issue duplicates using <a href="https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance">Damerau–Levenshtein</a> algorithm
|
||||
Search for potential issue duplicates using <a href="https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance">Damerau–Levenshtein</a> algorithm and close it.
|
||||
</strong>
|
||||
</p>
|
||||
|
||||
## Usage
|
||||
|
||||
Create `.github/workflows/potential-duplicates.yml` in the default branch:
|
||||
Create `.github/workflows/close-potential-duplicates.yml` in the default branch:
|
||||
|
||||
```yaml
|
||||
name: Potential Duplicates
|
||||
@ -30,7 +28,7 @@ jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: wow-actions/potential-duplicates@v1
|
||||
- uses: iv-org/close-potential-duplicates@v1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Issue title filter work with anymatch https://www.npmjs.com/package/anymatch.
|
||||
@ -48,6 +46,8 @@ jobs:
|
||||
# Reactions to be add to comment when potential duplicates are detected.
|
||||
# Available reactions: "-1", "+1", "confused", "laugh", "heart", "hooray", "rocket", "eyes"
|
||||
reactions: 'eyes, confused'
|
||||
# Close or not the issue: false or true
|
||||
close: 'false'
|
||||
# Comment to post when potential duplicates are detected.
|
||||
comment: >
|
||||
Potential duplicates: {{#issues}}
|
||||
@ -71,6 +71,7 @@ Various inputs are defined to let you configure the action:
|
||||
| `threshold` | If similarity is higher than this threshold(`[0,1]`), issue will be marked as duplicate | `0.6` |
|
||||
| `reactions` | Reactions to be add to comment when potential duplicates are detected <br> Available reactions: "-1", "+1", "confused", "laugh", "heart", "hooray", "rocket", "eyes" | |
|
||||
| `comment` | Comment to post when potential duplicates are detected | 👇 |
|
||||
| `close` | Close or not the issue when found to be duplicate. | false |
|
||||
|
||||
Available reactions:
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "potential-duplicates",
|
||||
"description": "Search for potential issue duplicates using Damerau–Levenshtein algorithm.",
|
||||
"version": "1.1.0",
|
||||
"version": "1.0.0",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
"dist",
|
||||
@ -33,7 +33,7 @@
|
||||
"email": "bubkoo.wy@gmail.com"
|
||||
},
|
||||
"contributors": [],
|
||||
"repository": "https://github.com/wow-actions/potential-duplicates",
|
||||
"repository": "https://github.com/iv-org/close-potential-duplicates",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/github": "^5.0.0",
|
||||
|
@ -67,6 +67,7 @@ export namespace Action {
|
||||
|
||||
const comment = core.getInput('comment')
|
||||
const reactions = core.getInput('reactions')
|
||||
const close = core.getInput('close') as 'false' | 'true'
|
||||
if (comment) {
|
||||
const body = mustache.render(comment, {
|
||||
issues: duplicates,
|
||||
@ -82,6 +83,14 @@ export namespace Action {
|
||||
await Reaction.add(octokit, data.id, reactions)
|
||||
}
|
||||
}
|
||||
|
||||
if (close === 'true') {
|
||||
octokit.rest.issues.update({
|
||||
...context.repo,
|
||||
issue_number: payload.number,
|
||||
state: 'closed',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user