mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 18:25:58 +08:00
feat: add welcome (#19)
* feat: add welcome * add * fix * add * add * add * fix * add doc * update
This commit is contained in:
202
dist/index.js
vendored
202
dist/index.js
vendored
@@ -1461,7 +1461,7 @@ exports.Octokit = Octokit;
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
var isPlainObject = __webpack_require__(3287);
|
||||
var isPlainObject = __webpack_require__(558);
|
||||
var universalUserAgent = __webpack_require__(5030);
|
||||
|
||||
function lowercaseKeys(object) {
|
||||
@@ -1849,6 +1849,52 @@ exports.endpoint = endpoint;
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 558:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
/*!
|
||||
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
function isObject(o) {
|
||||
return Object.prototype.toString.call(o) === '[object Object]';
|
||||
}
|
||||
|
||||
function isPlainObject(o) {
|
||||
var ctor,prot;
|
||||
|
||||
if (isObject(o) === false) return false;
|
||||
|
||||
// If has modified constructor
|
||||
ctor = o.constructor;
|
||||
if (ctor === undefined) return true;
|
||||
|
||||
// If has modified prototype
|
||||
prot = ctor.prototype;
|
||||
if (isObject(prot) === false) return false;
|
||||
|
||||
// If constructor does not have an Object-specific method
|
||||
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Most likely a plain Object
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.isPlainObject = isPlainObject;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8467:
|
||||
@@ -3361,7 +3407,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
||||
|
||||
var endpoint = __webpack_require__(9440);
|
||||
var universalUserAgent = __webpack_require__(5030);
|
||||
var isPlainObject = __webpack_require__(3287);
|
||||
var isPlainObject = __webpack_require__(9062);
|
||||
var nodeFetch = _interopDefault(__webpack_require__(467));
|
||||
var requestError = __webpack_require__(537);
|
||||
|
||||
@@ -3503,6 +3549,52 @@ exports.request = request;
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9062:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
/*!
|
||||
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
function isObject(o) {
|
||||
return Object.prototype.toString.call(o) === '[object Object]';
|
||||
}
|
||||
|
||||
function isPlainObject(o) {
|
||||
var ctor,prot;
|
||||
|
||||
if (isObject(o) === false) return false;
|
||||
|
||||
// If has modified constructor
|
||||
ctor = o.constructor;
|
||||
if (ctor === undefined) return true;
|
||||
|
||||
// If has modified prototype
|
||||
prot = ctor.prototype;
|
||||
if (isObject(prot) === false) return false;
|
||||
|
||||
// If constructor does not have an Object-specific method
|
||||
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Most likely a plain Object
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.isPlainObject = isPlainObject;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5375:
|
||||
@@ -3876,52 +3968,6 @@ module.exports.config = config
|
||||
module.exports.parse = parse
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3287:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
/*!
|
||||
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
function isObject(o) {
|
||||
return Object.prototype.toString.call(o) === '[object Object]';
|
||||
}
|
||||
|
||||
function isPlainObject(o) {
|
||||
var ctor,prot;
|
||||
|
||||
if (isObject(o) === false) return false;
|
||||
|
||||
// If has modified constructor
|
||||
ctor = o.constructor;
|
||||
if (ctor === undefined) return true;
|
||||
|
||||
// If has modified prototype
|
||||
prot = ctor.prototype;
|
||||
if (isObject(prot) === false) return false;
|
||||
|
||||
// If constructor does not have an Object-specific method
|
||||
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Most likely a plain Object
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.isPlainObject = isPlainObject;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 467:
|
||||
@@ -6146,7 +6192,7 @@ async function doLockIssues (owner, repo, labels) {
|
||||
}
|
||||
};
|
||||
|
||||
async function doQueryIssues (owner, repo, labels, state) {
|
||||
async function doQueryIssues (owner, repo, labels, state, creator) {
|
||||
let params = {
|
||||
owner,
|
||||
repo,
|
||||
@@ -6161,6 +6207,10 @@ async function doQueryIssues (owner, repo, labels, state) {
|
||||
params.labels = labels;
|
||||
}
|
||||
|
||||
if (creator) {
|
||||
params.creator = creator;
|
||||
}
|
||||
|
||||
const res = await octokit.issues.listForRepo(params);
|
||||
let issues = [];
|
||||
res.data.forEach(iss => {
|
||||
@@ -6193,6 +6243,9 @@ module.exports = {
|
||||
doCloseIssues,
|
||||
doFindComments,
|
||||
doLockIssues,
|
||||
|
||||
// tool
|
||||
doQueryIssues,
|
||||
};
|
||||
|
||||
|
||||
@@ -6203,8 +6256,11 @@ module.exports = {
|
||||
|
||||
__webpack_require__(2437).config();
|
||||
const core = __webpack_require__(2186);
|
||||
const github = __webpack_require__(5438);
|
||||
const { Octokit } = __webpack_require__(5375);
|
||||
|
||||
const { doQueryIssues } = __webpack_require__(9319);
|
||||
|
||||
const ALLREACTIONS = [
|
||||
"+1",
|
||||
"-1",
|
||||
@@ -6222,6 +6278,7 @@ const token = core.getInput('token');
|
||||
const octokit = new Octokit({ auth: `token ${token}` });
|
||||
|
||||
const contents = core.getInput("contents");
|
||||
const issueContents = core.getInput("issue-contents");
|
||||
|
||||
async function doAddAssignees (owner, repo, issueNumber, assignees) {
|
||||
await octokit.issues.addAssignees({
|
||||
@@ -6499,6 +6556,41 @@ async function doUpdateIssue (
|
||||
}
|
||||
};
|
||||
|
||||
async function doWelcome (owner, repo, assignees, labels, body) {
|
||||
const context = github.context;
|
||||
const isIssue = !!context.payload.issue;
|
||||
if (!isIssue) {
|
||||
core.setFailed("The event that triggered this action must be a issue. Error!");
|
||||
} else {
|
||||
const auth = context.payload.sender.login;
|
||||
core.info(`Actions: [welcome: auth=][${auth}]`);
|
||||
const issueNumber = context.issue.number;
|
||||
const creator = 'zoo-js-bot';
|
||||
const issues = await doQueryIssues(owner, repo, false, 'all', creator);
|
||||
if (issues.length == 0 || (issues.length == 1 && issues[0].number == issueNumber)) {
|
||||
if (core.getInput("body")) {
|
||||
await doCreateComment(owner, repo, issueNumber, body);
|
||||
} else {
|
||||
core.info(`Actions: [welcome] no body!`);
|
||||
}
|
||||
|
||||
if (assignees) {
|
||||
await doAddAssignees(owner, repo, issueNumber, assignees);
|
||||
}
|
||||
|
||||
if (labels) {
|
||||
await doAddLabels(owner, repo, issueNumber, labels);
|
||||
}
|
||||
|
||||
if (issueContents) {
|
||||
await doCreateIssueContent(owner, repo, issueNumber, dealInput(issueContents));
|
||||
}
|
||||
} else {
|
||||
core.info(`Actions: [welcome][${auth}] is not first time!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// tool
|
||||
function testContent(con) {
|
||||
if (ALLREACTIONS.includes(con)) {
|
||||
@@ -6527,6 +6619,7 @@ module.exports = {
|
||||
doUnlockIssue,
|
||||
doUpdateComment,
|
||||
doUpdateIssue,
|
||||
doWelcome,
|
||||
};
|
||||
|
||||
|
||||
@@ -6555,6 +6648,7 @@ const {
|
||||
doUnlockIssue,
|
||||
doUpdateComment,
|
||||
doUpdateIssue,
|
||||
doWelcome,
|
||||
} = __webpack_require__(9932);
|
||||
|
||||
const {
|
||||
@@ -6581,6 +6675,7 @@ const ALLACTIONS = [
|
||||
'unlock-issue',
|
||||
'update-comment',
|
||||
'update-issue',
|
||||
'welcome',
|
||||
|
||||
// advanced
|
||||
'check-inactive',
|
||||
@@ -6689,6 +6784,15 @@ async function main() {
|
||||
labels
|
||||
);
|
||||
break;
|
||||
case 'welcome':
|
||||
await doWelcome(
|
||||
owner,
|
||||
repo,
|
||||
assignees,
|
||||
labels,
|
||||
body
|
||||
);
|
||||
break;
|
||||
|
||||
// advanced
|
||||
case 'check-inactive':
|
||||
|
Reference in New Issue
Block a user