-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (61 loc) · 2.49 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/******************************************************/
/**
* @author Vedansh (offensive-vk)
* @url https://github.com/offensive-vk/auto-issue/
* @lang JavaScript + Node.js
* @type Github Action for Creating Issues.
* @uses Octokit and Actions Core
* @runs Nodejs v20.x
*/
/******************************************************/
const core = require('@actions/core');
const github = require('@actions/github');
const override = require('override.ps1');
const listToArray = (str = '') => str.split(',').map(item => item.trim());
(async () => {
try {
const token = core.getInput('github-token', { required: true });
core.debug(`Using token: ${token}`);
const { owner: contextOwner, repo: contextRepo } = github.context.repo;
const owner = core.getInput('owner') || contextOwner;
const repo = core.getInput('repo') || contextRepo;
const title = core.getInput('title') || 'Automated Issue by offensive-vk/auto-issue';
core.debug(`Using owner: ${owner}`);
core.debug(`Using repo: ${repo}`);
core.debug(`Using title: ${title}`);
const body = core.getInput('body');
const milestone = core.getInput('milestone');
const labels = core.getInput('labels');
const assignees = core.getInput('assignees');
core.debug(`Using body: """${body || ''}"""`);
core.debug(`Using milestone: ${milestone || ''}`);
core.debug(`Using labels: ${labels || ''}`);
core.debug(`Using assignees: ${assignees || ''}`);
const octokit = github.getOctokit(token);
const issueData = {
owner,
repo,
title,
body: body || null,
milestone: milestone || null,
labels: labels ? listToArray(labels) : null,
assignees: assignees ? listToArray(assignees) : null,
};
core.debug(`Issue payload: ${JSON.stringify(issueData, null, 2)}`);
const { data: newIssue } = await octokit.rest.issues.create(issueData);
core.info(`Issue created: ${newIssue.html_url}`);
core.setOutput('JSON', JSON.stringify(newIssue));
core.setOutput('NUMBER', newIssue.number);
core.setOutput('URL', newIssue.html_url);
console.log(`
-------------------------------------------------
🎉 Success! Issue has been created successfully.
Thank you for using this action! – Vedansh ✨
-------------------------------------------------
`);
} catch (error) {
core.error(error);
core.setFailed(`Failed to create issue: ${error.message}`);
}
})();
/******************************************************/