mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-21 19:25:46 +08:00
feat: add welcome (#19)
* feat: add welcome * add * fix * add * add * add * fix * add doc * update
This commit is contained in:
@@ -41,6 +41,7 @@ When the following list does not have the features you want, you can submit it i
|
|||||||
- [`unlock-issue`](#unlock-issue)
|
- [`unlock-issue`](#unlock-issue)
|
||||||
- [`update-comment`](#update-comment)
|
- [`update-comment`](#update-comment)
|
||||||
- [`update-issue`](#update-issue)
|
- [`update-issue`](#update-issue)
|
||||||
|
- [`welcome`](#welcome)
|
||||||
- ⭐ Advanced
|
- ⭐ Advanced
|
||||||
- [`check-inactive`](#check-inactive)
|
- [`check-inactive`](#check-inactive)
|
||||||
- [`check-issue`](#check-issue)
|
- [`check-issue`](#check-issue)
|
||||||
@@ -484,6 +485,47 @@ Update the specified issue according to the `issue-number`.
|
|||||||
|
|
||||||
⏫ [Back to list](#List)
|
⏫ [Back to list](#List)
|
||||||
|
|
||||||
|
#### `welcome`
|
||||||
|
|
||||||
|
When an issue is created, the user who created the issue for the first time is welcome.
|
||||||
|
|
||||||
|
If the user is not creating for the first time, there is no operation.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Issue Welcome
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
issue-welcome:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: welcome
|
||||||
|
uses: actions-cool/issues-helper@v1.3
|
||||||
|
with:
|
||||||
|
actions: 'welcome'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
body: hi @${{ github.event.issue.user.login }}, welcome!
|
||||||
|
labels: 'welcome1, welcome2'
|
||||||
|
assignees: 'xx1'
|
||||||
|
issue-contents: '+1, -1, eyes'
|
||||||
|
```
|
||||||
|
|
||||||
|
| Param | Desc | Type | Required | Version |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | Action type | string | ✔ | v1.3 |
|
||||||
|
| token | [Token explain](#token) | string | ✔ | v1.3 |
|
||||||
|
| body | Comment on the welcome content, no comment if you leave it blank | string | ✖ | v1.3 |
|
||||||
|
| labels | Add labels to this issue | string | ✖ | v1.3 |
|
||||||
|
| assignees | Add assignees to this issue | string | ✖ | v1.3 |
|
||||||
|
| issue-contents | Add [reaction](#reactions-types) to this issue| string | ✖ | v1.3 |
|
||||||
|
|
||||||
|
- If these 4 options are not filled, no operation
|
||||||
|
|
||||||
|
⏫ [Back to list](#List)
|
||||||
|
|
||||||
### 🌟 Advanced
|
### 🌟 Advanced
|
||||||
|
|
||||||
Advanced usage is not recommended to use multiple actions at the same time.
|
Advanced usage is not recommended to use multiple actions at the same time.
|
||||||
|
40
README.md
40
README.md
@@ -41,6 +41,7 @@
|
|||||||
- [`unlock-issue`](#unlock-issue)
|
- [`unlock-issue`](#unlock-issue)
|
||||||
- [`update-comment`](#update-comment)
|
- [`update-comment`](#update-comment)
|
||||||
- [`update-issue`](#update-issue)
|
- [`update-issue`](#update-issue)
|
||||||
|
- [`welcome`](#welcome)
|
||||||
- ⭐ 进 阶
|
- ⭐ 进 阶
|
||||||
- [`check-inactive`](#check-inactive)
|
- [`check-inactive`](#check-inactive)
|
||||||
- [`check-issue`](#check-issue)
|
- [`check-issue`](#check-issue)
|
||||||
@@ -484,6 +485,45 @@ jobs:
|
|||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `welcome`
|
||||||
|
|
||||||
|
当一个 issue 新建时,对首次新建 issue 的用户进行欢迎。若用户非首次新建,则无操作。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Issue Welcome
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
issue-welcome:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: welcome
|
||||||
|
uses: actions-cool/issues-helper@v1.3
|
||||||
|
with:
|
||||||
|
actions: 'welcome'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
body: hi @${{ github.event.issue.user.login }}, welcome!
|
||||||
|
labels: 'welcome1, welcome2'
|
||||||
|
assignees: 'xx1'
|
||||||
|
issue-contents: '+1, -1, eyes'
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | 操作类型 | string | ✔ | v1.3 |
|
||||||
|
| token | [token 说明](#token) | string | ✔ | v1.3 |
|
||||||
|
| body | 评论欢迎的内容,不填则不评论 | string | ✖ | v1.3 |
|
||||||
|
| labels | 为该 issue 增加 labels | string | ✖ | v1.3 |
|
||||||
|
| assignees | 为该 issue 增加 assignees | string | ✖ | v1.3 |
|
||||||
|
| issue-contents | 为该 issue 增加 [reaction](#reactions-types) | string | ✖ | v1.3 |
|
||||||
|
|
||||||
|
- 若这 4 个可选项都不填,则无操作
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
### 🌟 进 阶
|
### 🌟 进 阶
|
||||||
|
|
||||||
进阶用法不建议 actions 多个一次同时使用。
|
进阶用法不建议 actions 多个一次同时使用。
|
||||||
|
@@ -44,6 +44,8 @@ inputs:
|
|||||||
description: 'Query use'
|
description: 'Query use'
|
||||||
issue-mentioned:
|
issue-mentioned:
|
||||||
description: 'Query use'
|
description: 'Query use'
|
||||||
|
issue-contents:
|
||||||
|
description: 'For welcome'
|
||||||
issue-state:
|
issue-state:
|
||||||
description: 'Query use'
|
description: 'Query use'
|
||||||
inactive-day:
|
inactive-day:
|
||||||
|
202
dist/index.js
vendored
202
dist/index.js
vendored
@@ -1461,7 +1461,7 @@ exports.Octokit = Octokit;
|
|||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
|
||||||
var isPlainObject = __webpack_require__(3287);
|
var isPlainObject = __webpack_require__(558);
|
||||||
var universalUserAgent = __webpack_require__(5030);
|
var universalUserAgent = __webpack_require__(5030);
|
||||||
|
|
||||||
function lowercaseKeys(object) {
|
function lowercaseKeys(object) {
|
||||||
@@ -1849,6 +1849,52 @@ exports.endpoint = endpoint;
|
|||||||
//# sourceMappingURL=index.js.map
|
//# 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:
|
/***/ 8467:
|
||||||
@@ -3361,7 +3407,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|||||||
|
|
||||||
var endpoint = __webpack_require__(9440);
|
var endpoint = __webpack_require__(9440);
|
||||||
var universalUserAgent = __webpack_require__(5030);
|
var universalUserAgent = __webpack_require__(5030);
|
||||||
var isPlainObject = __webpack_require__(3287);
|
var isPlainObject = __webpack_require__(9062);
|
||||||
var nodeFetch = _interopDefault(__webpack_require__(467));
|
var nodeFetch = _interopDefault(__webpack_require__(467));
|
||||||
var requestError = __webpack_require__(537);
|
var requestError = __webpack_require__(537);
|
||||||
|
|
||||||
@@ -3503,6 +3549,52 @@ exports.request = request;
|
|||||||
//# sourceMappingURL=index.js.map
|
//# 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:
|
/***/ 5375:
|
||||||
@@ -3876,52 +3968,6 @@ module.exports.config = config
|
|||||||
module.exports.parse = parse
|
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:
|
/***/ 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 = {
|
let params = {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -6161,6 +6207,10 @@ async function doQueryIssues (owner, repo, labels, state) {
|
|||||||
params.labels = labels;
|
params.labels = labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (creator) {
|
||||||
|
params.creator = creator;
|
||||||
|
}
|
||||||
|
|
||||||
const res = await octokit.issues.listForRepo(params);
|
const res = await octokit.issues.listForRepo(params);
|
||||||
let issues = [];
|
let issues = [];
|
||||||
res.data.forEach(iss => {
|
res.data.forEach(iss => {
|
||||||
@@ -6193,6 +6243,9 @@ module.exports = {
|
|||||||
doCloseIssues,
|
doCloseIssues,
|
||||||
doFindComments,
|
doFindComments,
|
||||||
doLockIssues,
|
doLockIssues,
|
||||||
|
|
||||||
|
// tool
|
||||||
|
doQueryIssues,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -6203,8 +6256,11 @@ module.exports = {
|
|||||||
|
|
||||||
__webpack_require__(2437).config();
|
__webpack_require__(2437).config();
|
||||||
const core = __webpack_require__(2186);
|
const core = __webpack_require__(2186);
|
||||||
|
const github = __webpack_require__(5438);
|
||||||
const { Octokit } = __webpack_require__(5375);
|
const { Octokit } = __webpack_require__(5375);
|
||||||
|
|
||||||
|
const { doQueryIssues } = __webpack_require__(9319);
|
||||||
|
|
||||||
const ALLREACTIONS = [
|
const ALLREACTIONS = [
|
||||||
"+1",
|
"+1",
|
||||||
"-1",
|
"-1",
|
||||||
@@ -6222,6 +6278,7 @@ const token = core.getInput('token');
|
|||||||
const octokit = new Octokit({ auth: `token ${token}` });
|
const octokit = new Octokit({ auth: `token ${token}` });
|
||||||
|
|
||||||
const contents = core.getInput("contents");
|
const contents = core.getInput("contents");
|
||||||
|
const issueContents = core.getInput("issue-contents");
|
||||||
|
|
||||||
async function doAddAssignees (owner, repo, issueNumber, assignees) {
|
async function doAddAssignees (owner, repo, issueNumber, assignees) {
|
||||||
await octokit.issues.addAssignees({
|
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
|
// tool
|
||||||
function testContent(con) {
|
function testContent(con) {
|
||||||
if (ALLREACTIONS.includes(con)) {
|
if (ALLREACTIONS.includes(con)) {
|
||||||
@@ -6527,6 +6619,7 @@ module.exports = {
|
|||||||
doUnlockIssue,
|
doUnlockIssue,
|
||||||
doUpdateComment,
|
doUpdateComment,
|
||||||
doUpdateIssue,
|
doUpdateIssue,
|
||||||
|
doWelcome,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -6555,6 +6648,7 @@ const {
|
|||||||
doUnlockIssue,
|
doUnlockIssue,
|
||||||
doUpdateComment,
|
doUpdateComment,
|
||||||
doUpdateIssue,
|
doUpdateIssue,
|
||||||
|
doWelcome,
|
||||||
} = __webpack_require__(9932);
|
} = __webpack_require__(9932);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -6581,6 +6675,7 @@ const ALLACTIONS = [
|
|||||||
'unlock-issue',
|
'unlock-issue',
|
||||||
'update-comment',
|
'update-comment',
|
||||||
'update-issue',
|
'update-issue',
|
||||||
|
'welcome',
|
||||||
|
|
||||||
// advanced
|
// advanced
|
||||||
'check-inactive',
|
'check-inactive',
|
||||||
@@ -6689,6 +6784,15 @@ async function main() {
|
|||||||
labels
|
labels
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case 'welcome':
|
||||||
|
await doWelcome(
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
assignees,
|
||||||
|
labels,
|
||||||
|
body
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
// advanced
|
// advanced
|
||||||
case 'check-inactive':
|
case 'check-inactive':
|
||||||
|
@@ -405,3 +405,42 @@ Update the specified issue according to the `issue-number`.
|
|||||||
|
|
||||||
- `state` defaults to `open`
|
- `state` defaults to `open`
|
||||||
- When the option is not filled, it will keep the original
|
- When the option is not filled, it will keep the original
|
||||||
|
|
||||||
|
## `welcome`
|
||||||
|
|
||||||
|
When an issue is created, the user who created the issue for the first time is welcome.
|
||||||
|
|
||||||
|
If the user is not creating for the first time, there is no operation.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Issue Welcome
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
issue-welcome:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: welcome
|
||||||
|
uses: actions-cool/issues-helper@v1.3
|
||||||
|
with:
|
||||||
|
actions: 'welcome'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
body: hi @${{ github.event.issue.user.login }}, welcome!
|
||||||
|
labels: 'welcome1, welcome2'
|
||||||
|
assignees: 'xx1'
|
||||||
|
issue-contents: '+1, -1, eyes'
|
||||||
|
```
|
||||||
|
|
||||||
|
| Param | Desc | Type | Required | Version |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | Action type | string | ✔ | v1.3 |
|
||||||
|
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | v1.3 |
|
||||||
|
| body | Comment on the welcome content, no comment if you leave it blank | string | ✖ | v1.3 |
|
||||||
|
| labels | Add labels to this issue | string | ✖ | v1.3 |
|
||||||
|
| assignees | Add assignees to this issue | string | ✖ | v1.3 |
|
||||||
|
| issue-contents | Add [reaction](/en-US/guide/ref#-reactions-type) to this issue| string | ✖ | v1.3 |
|
||||||
|
|
||||||
|
- If these 4 options are not filled, no operation
|
38
docs/base.md
38
docs/base.md
@@ -405,3 +405,41 @@ jobs:
|
|||||||
|
|
||||||
- `state` 默认为 `open`
|
- `state` 默认为 `open`
|
||||||
- 当可选项不填时,会保持原有
|
- 当可选项不填时,会保持原有
|
||||||
|
|
||||||
|
|
||||||
|
## `welcome`
|
||||||
|
|
||||||
|
当一个 issue 新建时,对首次新建 issue 的用户进行欢迎。若用户非首次新建,则无操作。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Issue Welcome
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
issue-welcome:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: welcome
|
||||||
|
uses: actions-cool/issues-helper@v1.3
|
||||||
|
with:
|
||||||
|
actions: 'welcome'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
body: hi @${{ github.event.issue.user.login }}, welcome!
|
||||||
|
labels: 'welcome1, welcome2'
|
||||||
|
assignees: 'xx1'
|
||||||
|
issue-contents: '+1, -1, eyes'
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | 操作类型 | string | ✔ | v1.3 |
|
||||||
|
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ | v1.3 |
|
||||||
|
| body | 评论欢迎的内容,不填则不评论 | string | ✖ | v1.3 |
|
||||||
|
| labels | 为该 issue 增加 labels | string | ✖ | v1.3 |
|
||||||
|
| assignees | 为该 issue 增加 assignees | string | ✖ | v1.3 |
|
||||||
|
| issue-contents | 为该 issue 增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ | v1.3 |
|
||||||
|
|
||||||
|
- 若这 4 个可选项都不填,则无操作
|
@@ -21,20 +21,4 @@ toc: menu
|
|||||||
uses: actions-cool/issues-helper@main
|
uses: actions-cool/issues-helper@main
|
||||||
```
|
```
|
||||||
|
|
||||||
## v1.2
|
<embed src="./log.md"></embed>
|
||||||
|
|
||||||
`2020.12.25`
|
|
||||||
|
|
||||||
- feat: add check-issue & remove labels. [#12](https://github.com/actions-cool/issues-helper/pull/12)
|
|
||||||
|
|
||||||
## v1.1
|
|
||||||
|
|
||||||
`2020.12.24`
|
|
||||||
|
|
||||||
- fix: yml not support array. [#11](https://github.com/actions-cool/issues-helper/pull/11)
|
|
||||||
|
|
||||||
## v1
|
|
||||||
|
|
||||||
`2020.12.23`
|
|
||||||
|
|
||||||
🎉 First release.
|
|
||||||
|
@@ -21,20 +21,4 @@ toc: menu
|
|||||||
uses: actions-cool/issues-helper@main
|
uses: actions-cool/issues-helper@main
|
||||||
```
|
```
|
||||||
|
|
||||||
## v1.2
|
<embed src="./log.md"></embed>
|
||||||
|
|
||||||
`2020.12.25`
|
|
||||||
|
|
||||||
- feat: add check-issue & remove labels. [#12](https://github.com/actions-cool/issues-helper/pull/12)
|
|
||||||
|
|
||||||
## v1.1
|
|
||||||
|
|
||||||
`2020.12.24`
|
|
||||||
|
|
||||||
- fix: yml not support array. [#11](https://github.com/actions-cool/issues-helper/pull/11)
|
|
||||||
|
|
||||||
## v1
|
|
||||||
|
|
||||||
`2020.12.23`
|
|
||||||
|
|
||||||
🎉 First release.
|
|
||||||
|
23
docs/log.md
Normal file
23
docs/log.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
## v1.3
|
||||||
|
|
||||||
|
`2020.12.28`
|
||||||
|
|
||||||
|
- feat: add welcome. [#19](https://github.com/actions-cool/issues-helper/pull/19)
|
||||||
|
|
||||||
|
## v1.2
|
||||||
|
|
||||||
|
`2020.12.25`
|
||||||
|
|
||||||
|
- feat: add check-issue & remove labels. [#12](https://github.com/actions-cool/issues-helper/pull/12)
|
||||||
|
|
||||||
|
## v1.1
|
||||||
|
|
||||||
|
`2020.12.24`
|
||||||
|
|
||||||
|
- fix: yml not support array. [#11](https://github.com/actions-cool/issues-helper/pull/11)
|
||||||
|
|
||||||
|
## v1
|
||||||
|
|
||||||
|
`2020.12.23`
|
||||||
|
|
||||||
|
🎉 First release.
|
@@ -165,7 +165,7 @@ async function doLockIssues (owner, repo, labels) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function doQueryIssues (owner, repo, labels, state) {
|
async function doQueryIssues (owner, repo, labels, state, creator) {
|
||||||
let params = {
|
let params = {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -180,6 +180,10 @@ async function doQueryIssues (owner, repo, labels, state) {
|
|||||||
params.labels = labels;
|
params.labels = labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (creator) {
|
||||||
|
params.creator = creator;
|
||||||
|
}
|
||||||
|
|
||||||
const res = await octokit.issues.listForRepo(params);
|
const res = await octokit.issues.listForRepo(params);
|
||||||
let issues = [];
|
let issues = [];
|
||||||
res.data.forEach(iss => {
|
res.data.forEach(iss => {
|
||||||
@@ -212,4 +216,7 @@ module.exports = {
|
|||||||
doCloseIssues,
|
doCloseIssues,
|
||||||
doFindComments,
|
doFindComments,
|
||||||
doLockIssues,
|
doLockIssues,
|
||||||
|
|
||||||
|
// tool
|
||||||
|
doQueryIssues,
|
||||||
};
|
};
|
||||||
|
40
src/base.js
40
src/base.js
@@ -1,7 +1,10 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
|
const github = require("@actions/github");
|
||||||
const { Octokit } = require('@octokit/rest');
|
const { Octokit } = require('@octokit/rest');
|
||||||
|
|
||||||
|
const { doQueryIssues } = require('./advanced.js');
|
||||||
|
|
||||||
const ALLREACTIONS = [
|
const ALLREACTIONS = [
|
||||||
"+1",
|
"+1",
|
||||||
"-1",
|
"-1",
|
||||||
@@ -19,6 +22,7 @@ const token = core.getInput('token');
|
|||||||
const octokit = new Octokit({ auth: `token ${token}` });
|
const octokit = new Octokit({ auth: `token ${token}` });
|
||||||
|
|
||||||
const contents = core.getInput("contents");
|
const contents = core.getInput("contents");
|
||||||
|
const issueContents = core.getInput("issue-contents");
|
||||||
|
|
||||||
async function doAddAssignees (owner, repo, issueNumber, assignees) {
|
async function doAddAssignees (owner, repo, issueNumber, assignees) {
|
||||||
await octokit.issues.addAssignees({
|
await octokit.issues.addAssignees({
|
||||||
@@ -296,6 +300,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
|
// tool
|
||||||
function testContent(con) {
|
function testContent(con) {
|
||||||
if (ALLREACTIONS.includes(con)) {
|
if (ALLREACTIONS.includes(con)) {
|
||||||
@@ -324,4 +363,5 @@ module.exports = {
|
|||||||
doUnlockIssue,
|
doUnlockIssue,
|
||||||
doUpdateComment,
|
doUpdateComment,
|
||||||
doUpdateIssue,
|
doUpdateIssue,
|
||||||
|
doWelcome,
|
||||||
};
|
};
|
||||||
|
11
src/main.js
11
src/main.js
@@ -18,6 +18,7 @@ const {
|
|||||||
doUnlockIssue,
|
doUnlockIssue,
|
||||||
doUpdateComment,
|
doUpdateComment,
|
||||||
doUpdateIssue,
|
doUpdateIssue,
|
||||||
|
doWelcome,
|
||||||
} = require('./base.js');
|
} = require('./base.js');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -44,6 +45,7 @@ const ALLACTIONS = [
|
|||||||
'unlock-issue',
|
'unlock-issue',
|
||||||
'update-comment',
|
'update-comment',
|
||||||
'update-issue',
|
'update-issue',
|
||||||
|
'welcome',
|
||||||
|
|
||||||
// advanced
|
// advanced
|
||||||
'check-inactive',
|
'check-inactive',
|
||||||
@@ -152,6 +154,15 @@ async function main() {
|
|||||||
labels
|
labels
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case 'welcome':
|
||||||
|
await doWelcome(
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
assignees,
|
||||||
|
labels,
|
||||||
|
body
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
// advanced
|
// advanced
|
||||||
case 'check-inactive':
|
case 'check-inactive':
|
||||||
|
Reference in New Issue
Block a user