From e348bddf559695c7c3f0ecca6e3b3b29288408e2 Mon Sep 17 00:00:00 2001 From: cyn Date: Fri, 2 Sep 2022 16:37:47 +0800 Subject: [PATCH] feat: add `get-issue` (#114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add get-issue * optimize code * fix * t * ttt * revert * revert Co-authored-by: 元凛 --- action.yml | 12 +++++++++++- dist/index.js | 20 +++++++++++++++++++- package.json | 4 +++- src/helper/base.ts | 13 +++++++++++++ src/helper/helper.ts | 5 +++++ src/issue/issue.ts | 2 +- src/types.ts | 1 + web/docs/advanced.en-US.md | 2 +- 8 files changed, 54 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 9ec4d5ed..83305150 100644 --- a/action.yml +++ b/action.yml @@ -96,7 +96,17 @@ inputs: outputs: issue-number: - description: 'Create Issue Number' + description: 'Issue Number' + issue-title: + description: 'Issue Title' + issue-body: + description: 'Issue Body' + issue-labels: + description: 'Issue labels' + issue-assignees: + description: 'Issue assignees' + issue-state: + description: 'Issue state' comment-id: description: 'Create comment ID' comments: diff --git a/dist/index.js b/dist/index.js index 0b0ca35c..d5117e2d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -15014,7 +15014,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.doUpdateIssue = exports.doUpdateComment = exports.doUnlockIssue = exports.doSetLabels = exports.doRemoveLabels = exports.doRemoveAssignees = exports.doOpenIssue = exports.doLockIssue = exports.doDeleteComment = exports.doCreateLabel = exports.doCreateIssue = exports.doCreateCommentEmoji = exports.doCreateComment = exports.doCloseIssue = exports.doAddLabels = exports.doAddAssignees = exports.initBaseICE = void 0; +exports.doUpdateIssue = exports.doUpdateComment = exports.doUnlockIssue = exports.doSetLabels = exports.doRemoveLabels = exports.doRemoveAssignees = exports.doOpenIssue = exports.doLockIssue = exports.doGetIssue = exports.doDeleteComment = exports.doCreateLabel = exports.doCreateIssue = exports.doCreateCommentEmoji = exports.doCreateComment = exports.doCloseIssue = exports.doAddLabels = exports.doAddAssignees = exports.initBaseICE = void 0; const actions_util_1 = __nccwpck_require__(6972); const core = __importStar(__nccwpck_require__(9875)); const shared_1 = __nccwpck_require__(3826); @@ -15125,6 +15125,20 @@ function doDeleteComment(_commentId) { }); } exports.doDeleteComment = doDeleteComment; +function doGetIssue() { + return __awaiter(this, void 0, void 0, function* () { + const { number, title, body, state, labels, assignees } = yield ICE.getIssue(); + core.setOutput('issue-number', number); + core.setOutput('issue-title', title || ''); + core.setOutput('issue-body', body || ''); + core.setOutput('issue-state', state); + const labelsString = labels.length ? labels.map(({ name }) => name).join(',') : ''; + core.setOutput('issue-labels', labelsString); + const assigneesString = assignees.length ? assignees.map(({ login }) => login).join(',') : ''; + core.setOutput('issue-body', assigneesString); + }); +} +exports.doGetIssue = doGetIssue; function doLockIssue(issueNumber) { return __awaiter(this, void 0, void 0, function* () { if (issueNumber) @@ -15345,6 +15359,10 @@ class IssueHelperEngine { yield (0, base_1.doDeleteComment)(); break; } + case 'get-issue': { + yield (0, base_1.doGetIssue)(); + break; + } case 'lock-issue': { yield (0, base_1.doLockIssue)(); break; diff --git a/package.json b/package.json index e7093f7e..dcd68019 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,8 @@ "format-check": "prettier --check **/*.ts **/*/*.ts", "lint": "eslint src/*.ts src/*/*.ts", "lint-fix": "eslint src/*.ts src/*/*.ts --fix", + "lint-up": "npm run format && npm run lint-fix", + "lint-all": "npm run format-check && npm run lint", "check-commit": "node ./scripts/check-commit.js", "tag": "node ./scripts/tag.js", "release": "node ./scripts/release", @@ -27,7 +29,7 @@ "users": "node ./scripts/update-users.js", "version": "node ./scripts/update-version.js", "pub": "sh -e ./scripts/pub.sh", - "all": "npm run format-check && npm run lint && npm run test && npm run package" + "all": "npm run lint-all && npm run test && npm run package" }, "dependencies": { "@actions/core": "^1.6.0", diff --git a/src/helper/base.ts b/src/helper/base.ts index c83914ec..b8d828c9 100644 --- a/src/helper/base.ts +++ b/src/helper/base.ts @@ -95,6 +95,19 @@ export async function doDeleteComment(_commentId: number | void) { } } +export async function doGetIssue() { + const { number, title, body, state, labels, assignees } = await ICE.getIssue(); + + core.setOutput('issue-number', number); + core.setOutput('issue-title', title || ''); + core.setOutput('issue-body', body || ''); + core.setOutput('issue-state', state); + const labelsString = labels.length ? labels.map(({ name }) => name).join(',') : ''; + core.setOutput('issue-labels', labelsString); + const assigneesString = assignees.length ? assignees.map(({ login }) => login).join(',') : ''; + core.setOutput('issue-body', assigneesString); +} + export async function doLockIssue(issueNumber?: number) { if (issueNumber) ICE.setIssueNumber(issueNumber); const lockReason = (core.getInput('lock-reason') || '') as TLockReasons; diff --git a/src/helper/helper.ts b/src/helper/helper.ts index 4bf5b99f..0dc31777 100644 --- a/src/helper/helper.ts +++ b/src/helper/helper.ts @@ -25,6 +25,7 @@ import { doCreateIssue, doCreateLabel, doDeleteComment, + doGetIssue, doLockIssue, doOpenIssue, doRemoveAssignees, @@ -159,6 +160,10 @@ export class IssueHelperEngine implements IIssueHelperEngine { await doDeleteComment(); break; } + case 'get-issue': { + await doGetIssue(); + break; + } case 'lock-issue': { await doLockIssue(); break; diff --git a/src/issue/issue.ts b/src/issue/issue.ts index b470f527..8630285e 100644 --- a/src/issue/issue.ts +++ b/src/issue/issue.ts @@ -2,12 +2,12 @@ import { Octokit } from '@octokit/rest'; import { EEmoji } from '../shared'; import type { + TCloseReason, TEmoji, TIssueState, TLockReasons, TUpdateMode, TUserPermission, - TCloseReason, } from '../types'; import type { IIssueBaseInfo, diff --git a/src/types.ts b/src/types.ts index c379ea5d..27f29c2f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -52,6 +52,7 @@ export type TAction = | 'close-issues' | 'find-comments' | 'find-issues' + | 'get-issue' | 'lock-issues' | 'mark-assignees' | 'mark-duplicate' diff --git a/web/docs/advanced.en-US.md b/web/docs/advanced.en-US.md index 0b4ef685..b06838fb 100644 --- a/web/docs/advanced.en-US.md +++ b/web/docs/advanced.en-US.md @@ -177,7 +177,7 @@ Find the current warehouse issue No. 1, the creator is k and the content contain - `direction` defaults to ascending order, only when `desc` is set, descending order will be returned - The `created` `updated` in the returned array, determined by the environment, will be UTC +0 -### `find-issues` +## `find-issues` Find the current repository, the creator is k , the title contains `this` , the body contains `that`, and the list of issues in the open state.