This commit is contained in:
xrkffgg
2020-12-21 18:47:11 +08:00
parent 2bf814f456
commit f68fa4769d
6 changed files with 98 additions and 15 deletions

View File

@@ -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);