mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 10:15:59 +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"
|
"@octokit/rest": "^18.0.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"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 core = require("@actions/core");
|
||||||
const github = require("@actions/github");
|
const github = require("@actions/github");
|
||||||
const { Octokit } = require('@octokit/rest');
|
const { Octokit } = require('@octokit/rest');
|
||||||
|
|
||||||
const REACTION_TYPES = [
|
const {
|
||||||
"+1",
|
doAddAssignees
|
||||||
"-1",
|
} = require('./tool');
|
||||||
"laugh",
|
|
||||||
"confused",
|
const ALLACTIONS = [
|
||||||
"heart",
|
'add-assignees',
|
||||||
"hooray",
|
'add-labels'
|
||||||
"rocket",
|
|
||||||
"eyes",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token') || process.env.GH_TOKEN;
|
||||||
const owner = github.context.repo.owner;
|
|
||||||
const repo = github.context.repo.repo;
|
const octokit = new Octokit({ auth: `token ${token}` });
|
||||||
console.log(owner, repo)
|
// 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) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
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