mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 18:25:58 +08:00
wip
This commit is contained in:
@@ -1 +1,8 @@
|
||||
# issue-helper
|
||||
# Issue Helper
|
||||
|
||||
A GitHub action to help you deal with the issue.
|
||||
|
||||
## Usage
|
||||
|
||||
### `add-assignees`
|
||||
|
||||
|
8
README.zh-CN.md
Normal file
8
README.zh-CN.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Issue Helper
|
||||
|
||||
一个可以帮助你处理 issue 的 GitHub Action。
|
||||
|
||||
## 使用
|
||||
|
||||
|
||||
|
@@ -26,6 +26,7 @@
|
||||
"@octokit/rest": "^18.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.25.1"
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
"dotenv": "^8.2.0"
|
||||
}
|
||||
}
|
||||
|
62
src/main.js
62
src/main.js
@@ -1,24 +1,60 @@
|
||||
require('dotenv').config();
|
||||
|
||||
const core = require("@actions/core");
|
||||
const github = require("@actions/github");
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
|
||||
const REACTION_TYPES = [
|
||||
"+1",
|
||||
"-1",
|
||||
"laugh",
|
||||
"confused",
|
||||
"heart",
|
||||
"hooray",
|
||||
"rocket",
|
||||
"eyes",
|
||||
const {
|
||||
doAddAssignees
|
||||
} = require('./tool');
|
||||
|
||||
const ALLACTIONS = [
|
||||
'add-assignees',
|
||||
'add-labels'
|
||||
];
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const token = core.getInput('token');
|
||||
const owner = github.context.repo.owner;
|
||||
const repo = github.context.repo.repo;
|
||||
console.log(owner, repo)
|
||||
const token = core.getInput('token') || process.env.GH_TOKEN;
|
||||
|
||||
const octokit = new Octokit({ auth: `token ${token}` });
|
||||
// const owner = github.context.repo.owner;
|
||||
// const repo = github.context.repo.repo;
|
||||
const owner = 'actions-cool';
|
||||
const repo = 'issue-helper';
|
||||
const issueNumber = core.getInput('issue-number') || 1;
|
||||
const commentId = core.getInput('comment-id');
|
||||
const body = core.getInput("body");
|
||||
// const assignees = core.getInput("assignees");
|
||||
const assignees = 'xrkffgg'
|
||||
|
||||
const actions = ['add-assignees', 'add-labels'];
|
||||
// const actions = core.getInput("actions", { required: true });
|
||||
|
||||
if (typeof(actions) === 'object') {
|
||||
actions.forEach(item => {
|
||||
testActions(item);
|
||||
})
|
||||
} else {
|
||||
testActions(actions);
|
||||
}
|
||||
|
||||
function testActions(action) {
|
||||
if (ALLACTIONS.includes(action)) {
|
||||
choseActions(action);
|
||||
} else {
|
||||
core.setFailed("This actions not supported!");
|
||||
}
|
||||
};
|
||||
|
||||
async function choseActions(action) {
|
||||
switch (action) {
|
||||
case 'add-assignees':
|
||||
await doAddAssignees(octokit, owner, repo, issueNumber, assignees);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
30
src/tool.js
Normal file
30
src/tool.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const REACTION_TYPES = [
|
||||
"+1",
|
||||
"-1",
|
||||
"laugh",
|
||||
"confused",
|
||||
"heart",
|
||||
"hooray",
|
||||
"rocket",
|
||||
"eyes",
|
||||
];
|
||||
|
||||
const doAddAssignees = async ({
|
||||
octokit,
|
||||
owner,
|
||||
repo,
|
||||
issueNumber,
|
||||
assignees
|
||||
}) => {
|
||||
await octokit.issues.addAssignees({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
assignees
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
doAddAssignees
|
||||
};
|
Reference in New Issue
Block a user