mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 18:25:58 +08:00
wip
This commit is contained in:
@@ -7,6 +7,45 @@ const octokit = new Octokit({ auth: `token ${token}` });
|
||||
|
||||
const commentAuth = core.getInput("comment-auth") || 'xrkffgg';
|
||||
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) {
|
||||
const res = await octokit.issues.listComments({
|
||||
@@ -28,6 +67,10 @@ async function doFindComments (owner, repo, issueNumber) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
doCloseIssues,
|
||||
doFindComments,
|
||||
};
|
||||
|
17
src/main.js
17
src/main.js
@@ -20,6 +20,7 @@ const {
|
||||
} = require('./base.js');
|
||||
|
||||
const {
|
||||
doCloseIssues,
|
||||
doFindComments,
|
||||
} = require('./advanced.js');
|
||||
|
||||
@@ -40,7 +41,9 @@ const ALLACTIONS = [
|
||||
'update-issue',
|
||||
|
||||
// advanced
|
||||
'close-issues',
|
||||
'find-comments',
|
||||
'lock-issues',
|
||||
];
|
||||
|
||||
async function main() {
|
||||
@@ -61,7 +64,7 @@ async function main() {
|
||||
|
||||
const assignees = core.getInput("assignees");
|
||||
|
||||
const labels = core.getInput("labels");
|
||||
const labels = core.getInput("labels") || ['test'];
|
||||
const state = core.getInput("state") || 'open';
|
||||
|
||||
let updateMode = core.getInput("update-mode") || 'replace';
|
||||
@@ -70,7 +73,7 @@ async function main() {
|
||||
}
|
||||
|
||||
// const actions = core.getInput("actions", { required: true });
|
||||
const actions = 'find-comments';
|
||||
const actions = 'close-issues';
|
||||
|
||||
if (typeof(actions) === 'object') {
|
||||
actions.forEach(item => {
|
||||
@@ -146,7 +149,15 @@ async function main() {
|
||||
labels
|
||||
);
|
||||
break;
|
||||
|
||||
// advanced
|
||||
case 'close-issues':
|
||||
await doCloseIssues(
|
||||
owner,
|
||||
repo,
|
||||
labels
|
||||
)
|
||||
break;
|
||||
case 'find-comments':
|
||||
await doFindComments(
|
||||
owner,
|
||||
@@ -155,8 +166,6 @@ async function main() {
|
||||
);
|
||||
break;
|
||||
|
||||
// ultimate
|
||||
|
||||
// default
|
||||
default:
|
||||
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