mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-10-14 07:43:46 +08:00
wip
This commit is contained in:
10
README.md
10
README.md
@@ -30,8 +30,6 @@ English | [简体中文](./README.zh-CN.md)
|
|||||||
- [`update-issue`](#update-issue)
|
- [`update-issue`](#update-issue)
|
||||||
- ⭐ 进 阶
|
- ⭐ 进 阶
|
||||||
- [`find-comments`](#find-comments)
|
- [`find-comments`](#find-comments)
|
||||||
- ⭐ 高 级
|
|
||||||
- 222
|
|
||||||
- 🌰 例 子
|
- 🌰 例 子
|
||||||
- [`find-comments + create-comment + update-comment`](#find-comments--create-comment--update-comment)
|
- [`find-comments + create-comment + update-comment`](#find-comments--create-comment--update-comment)
|
||||||
|
|
||||||
@@ -477,8 +475,6 @@ jobs:
|
|||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
### ⭐ 高 级
|
|
||||||
|
|
||||||
## 🌰 例 子
|
## 🌰 例 子
|
||||||
|
|
||||||
以下列举一些例子,请灵活参考。
|
以下列举一些例子,请灵活参考。
|
||||||
@@ -547,7 +543,8 @@ jobs:
|
|||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
### 输出使用
|
### `outputs` 使用
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
- name: Create issue
|
- name: Create issue
|
||||||
uses: actions-cool/issue-helper@v1
|
uses: actions-cool/issue-helper@v1
|
||||||
@@ -558,6 +555,7 @@ jobs:
|
|||||||
- name: Check outputs
|
- name: Check outputs
|
||||||
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
|
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
### GitHub Docs
|
### GitHub Docs
|
||||||
|
|
||||||
- [GitHub Actions 语法](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
|
- [GitHub Actions 语法](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
|
||||||
@@ -586,7 +584,7 @@ jobs:
|
|||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
## 谁在使用?
|
## 💖 谁在使用?
|
||||||
|
|
||||||
## LICENSE
|
## LICENSE
|
||||||
|
|
||||||
|
@@ -7,6 +7,45 @@ const octokit = new Octokit({ auth: `token ${token}` });
|
|||||||
|
|
||||||
const commentAuth = core.getInput("comment-auth") || 'xrkffgg';
|
const commentAuth = core.getInput("comment-auth") || 'xrkffgg';
|
||||||
const bodyIncludes = core.getInput('body-includes') || 'is';
|
const bodyIncludes = core.getInput('body-includes') || 'is';
|
||||||
|
const titleIncludes = core.getInput('title-includes') || 'test';
|
||||||
|
|
||||||
|
const issueCreator = core.getInput("issue-creator") || 'xrkffgg';
|
||||||
|
const issueAssignee = core.getInput('issue-assignee');
|
||||||
|
const issueMentioned = core.getInput('issue-mentioned');
|
||||||
|
|
||||||
|
async function doCloseIssues (owner, repo, labels) {
|
||||||
|
let params = {
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
state: 'open',
|
||||||
|
};
|
||||||
|
|
||||||
|
issueCreator ? params.creator = issueCreator : null;
|
||||||
|
issueAssignee ? params.assignee = issueAssignee : null;
|
||||||
|
issueMentioned ? params.mentioned = issueMentioned : null;
|
||||||
|
|
||||||
|
if (labels) {
|
||||||
|
if (typeof(labels) === 'string') {
|
||||||
|
params.labels = labels;
|
||||||
|
} else {
|
||||||
|
let temp = '';
|
||||||
|
labels.forEach((it,index) => {
|
||||||
|
index == labels.length - 1 ? temp += `${it}` : temp += `${it},`;
|
||||||
|
})
|
||||||
|
params.labels = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(params.labels)
|
||||||
|
|
||||||
|
const res = await octokit.issues.listForRepo(params);
|
||||||
|
console.log(res);
|
||||||
|
let issues = [];
|
||||||
|
for (let i = 0; i < res.data.length; i++) {
|
||||||
|
wip
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
async function doFindComments (owner, repo, issueNumber) {
|
async function doFindComments (owner, repo, issueNumber) {
|
||||||
const res = await octokit.issues.listComments({
|
const res = await octokit.issues.listComments({
|
||||||
@@ -28,6 +67,10 @@ async function doFindComments (owner, repo, issueNumber) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
doCloseIssues,
|
||||||
doFindComments,
|
doFindComments,
|
||||||
};
|
};
|
||||||
|
17
src/main.js
17
src/main.js
@@ -20,6 +20,7 @@ const {
|
|||||||
} = require('./base.js');
|
} = require('./base.js');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
doCloseIssues,
|
||||||
doFindComments,
|
doFindComments,
|
||||||
} = require('./advanced.js');
|
} = require('./advanced.js');
|
||||||
|
|
||||||
@@ -40,7 +41,9 @@ const ALLACTIONS = [
|
|||||||
'update-issue',
|
'update-issue',
|
||||||
|
|
||||||
// advanced
|
// advanced
|
||||||
|
'close-issues',
|
||||||
'find-comments',
|
'find-comments',
|
||||||
|
'lock-issues',
|
||||||
];
|
];
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -61,7 +64,7 @@ async function main() {
|
|||||||
|
|
||||||
const assignees = core.getInput("assignees");
|
const assignees = core.getInput("assignees");
|
||||||
|
|
||||||
const labels = core.getInput("labels");
|
const labels = core.getInput("labels") || ['test'];
|
||||||
const state = core.getInput("state") || 'open';
|
const state = core.getInput("state") || 'open';
|
||||||
|
|
||||||
let updateMode = core.getInput("update-mode") || 'replace';
|
let updateMode = core.getInput("update-mode") || 'replace';
|
||||||
@@ -70,7 +73,7 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// const actions = core.getInput("actions", { required: true });
|
// const actions = core.getInput("actions", { required: true });
|
||||||
const actions = 'find-comments';
|
const actions = 'close-issues';
|
||||||
|
|
||||||
if (typeof(actions) === 'object') {
|
if (typeof(actions) === 'object') {
|
||||||
actions.forEach(item => {
|
actions.forEach(item => {
|
||||||
@@ -146,7 +149,15 @@ async function main() {
|
|||||||
labels
|
labels
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// advanced
|
// advanced
|
||||||
|
case 'close-issues':
|
||||||
|
await doCloseIssues(
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
labels
|
||||||
|
)
|
||||||
|
break;
|
||||||
case 'find-comments':
|
case 'find-comments':
|
||||||
await doFindComments(
|
await doFindComments(
|
||||||
owner,
|
owner,
|
||||||
@@ -155,8 +166,6 @@ async function main() {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ultimate
|
|
||||||
|
|
||||||
// default
|
// default
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
require('dotenv').config();
|
|
||||||
const core = require("@actions/core");
|
|
||||||
const { Octokit } = require('@octokit/rest');
|
|
||||||
|
|
||||||
const token = core.getInput('token') || process.env.GH_TOKEN;
|
|
||||||
const octokit = new Octokit({ auth: `token ${token}` });
|
|
Reference in New Issue
Block a user