Browse Source
* Delete reply-issue.yml * Create issue-open-check.yml * Delete issue.jspull/8249/head
committed by
GitHub
3 changed files with 34 additions and 129 deletions
@ -0,0 +1,34 @@ |
|||||
|
name: Issue Open Check |
||||
|
|
||||
|
on: |
||||
|
issues: |
||||
|
types: [opened, edited] |
||||
|
|
||||
|
jobs: |
||||
|
check-issue: |
||||
|
runs-on: ubuntu-latest |
||||
|
steps: |
||||
|
- uses: actions-cool/issues-helper@v2.2.0 |
||||
|
id: check |
||||
|
with: |
||||
|
actions: 'check-issue' |
||||
|
issue-number: ${{ github.event.issue.number }} |
||||
|
title-excludes: '🐛[BUG], 👑 [需求], 🧐[问题]' |
||||
|
|
||||
|
- if: steps.check.outputs.check-result == 'false' |
||||
|
uses: actions-cool/issues-helper@v2.2.0 |
||||
|
with: |
||||
|
actions: 'create-comment, close-issue' |
||||
|
issue-number: ${{ github.event.issue.number }} |
||||
|
body: | |
||||
|
当前 Issue 未检测到标题,请规范填写,谢谢! |
||||
|
|
||||
|
The title of the current issue is not detected, please fill in according to the specifications, thank you! |
||||
|
|
||||
|
- if: steps.check.outputs.check-result == 'true' |
||||
|
uses: actions-cool/issues-similarity-analysis@v1.0.0 |
||||
|
with: |
||||
|
filter-threshold: 0.7 |
||||
|
title-excludes: '🐛[BUG], 👑 [需求], 🧐[问题]' |
||||
|
comment-title: '### 以下的 Issues 可能会帮助到你 / The following issues may help you' |
||||
|
show-footer: false |
||||
@ -1,44 +0,0 @@ |
|||||
name: auto issue |
|
||||
|
|
||||
on: |
|
||||
issues: |
|
||||
types: [opened] |
|
||||
|
|
||||
jobs: |
|
||||
reply: |
|
||||
runs-on: ubuntu-latest |
|
||||
steps: |
|
||||
- uses: actions/checkout@v2 |
|
||||
- name: Use Node.js ${{ matrix.node_version }} |
|
||||
uses: actions/setup-node@v1 |
|
||||
with: |
|
||||
node-version: ${{ matrix.node_version }} |
|
||||
- name: Get yarn cache directory path |
|
||||
id: yarn-cache-dir-path |
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)" |
|
||||
- name: Cache yarn cache |
|
||||
uses: actions/cache@v2 |
|
||||
id: cache-yarn-cache |
|
||||
with: |
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
|
||||
restore-keys: | |
|
||||
${{ runner.os }}-yarn- |
|
||||
- name: Cache node_modules |
|
||||
id: cache-node-modules |
|
||||
uses: actions/cache@v2 |
|
||||
with: |
|
||||
path: node_modules |
|
||||
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }} |
|
||||
restore-keys: | |
|
||||
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- |
|
||||
- run: yarn --ignore-engines |
|
||||
if: | |
|
||||
steps.cache-yarn-cache.outputs.cache-hit != 'true' || |
|
||||
steps.cache-node-modules.outputs.cache-hit != 'true' |
|
||||
- run: yarn add @octokit/core |
|
||||
- name: Auto reply to issue |
|
||||
env: |
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }} |
|
||||
run: node ./tests/issue.js |
|
||||
@ -1,85 +0,0 @@ |
|||||
const Octokit = require('@octokit/core'); |
|
||||
|
|
||||
const octokit = new Octokit.Octokit({ |
|
||||
auth: process.env.GITHUB_TOKEN || process.env.GITHUB_AUTH, |
|
||||
}); |
|
||||
|
|
||||
const queryIssue = ({ title, id }) => { |
|
||||
return octokit |
|
||||
.request('GET /search/issues', { |
|
||||
q: title, |
|
||||
per_page: 5, |
|
||||
}) |
|
||||
.then(({ data }) => { |
|
||||
const list = data.items |
|
||||
.map((item) => { |
|
||||
return { |
|
||||
title: item.title, |
|
||||
url: item.html_url, |
|
||||
id: item.id, |
|
||||
}; |
|
||||
}) |
|
||||
.filter((item) => { |
|
||||
return item.id !== id; |
|
||||
}); |
|
||||
|
|
||||
if (list.length > 0) { |
|
||||
return ` |
|
||||
> Issue Robot generation |
|
||||
|
|
||||
### 以下的issue可能会帮助到你 : |
|
||||
|
|
||||
${list |
|
||||
.map((item) => { |
|
||||
return `* [${item.title}](${item.url})`; |
|
||||
}) |
|
||||
.join('\n')}`;
|
|
||||
} |
|
||||
return null; |
|
||||
}) |
|
||||
.then(async (markdown) => { |
|
||||
return markdown; |
|
||||
}); |
|
||||
}; |
|
||||
|
|
||||
const findIssue = async (issueId) => { |
|
||||
const { data } = await octokit.request('GET /repos/{owner}/{repo}/issues/{issue_number}', { |
|
||||
owner: 'ant-design', |
|
||||
repo: 'ant-design-pro', |
|
||||
issue_number: issueId, |
|
||||
}); |
|
||||
return data; |
|
||||
}; |
|
||||
const closeIssue = async (issueId) => { |
|
||||
await octokit.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', { |
|
||||
owner: 'ant-design', |
|
||||
repo: 'ant-design-pro', |
|
||||
issue_number: issueId, |
|
||||
state: 'closed', |
|
||||
}); |
|
||||
}; |
|
||||
const replyCommit = async (issueId, markdown) => { |
|
||||
await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', { |
|
||||
owner: 'ant-design', |
|
||||
repo: 'ant-design-pro', |
|
||||
issue_number: issueId, |
|
||||
body: markdown, |
|
||||
}); |
|
||||
}; |
|
||||
|
|
||||
const reply = async () => { |
|
||||
const issueId = process.env.ISSUE_NUMBER; |
|
||||
const issue = await findIssue(issueId); |
|
||||
if (!issue.title || issue.title.length < 12) { |
|
||||
replyCommit(issueId, '**请写标题!**'); |
|
||||
closeIssue(issueId); |
|
||||
return; |
|
||||
} |
|
||||
// const markdown = await queryIssue({
|
|
||||
// title: issue.title,
|
|
||||
// id: issue.id,
|
|
||||
// });
|
|
||||
// replyCommit(issueId, markdown);
|
|
||||
}; |
|
||||
|
|
||||
reply(); |
|
||||
Loading…
Reference in new issue