Skip to content

Commit

Permalink
feat: add get-issue (#114)
Browse files Browse the repository at this point in the history
* feat: add get-issue

* optimize code

* fix

* t

* ttt

* revert

* revert

Co-authored-by: 元凛 <[email protected]>
  • Loading branch information
timeTravelCYN and xrkffgg authored Sep 2, 2022
1 parent adce2a7 commit e348bdd
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 5 deletions.
12 changes: 11 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 19 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions src/helper/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/helper/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
doCreateIssue,
doCreateLabel,
doDeleteComment,
doGetIssue,
doLockIssue,
doOpenIssue,
doRemoveAssignees,
Expand Down Expand Up @@ -159,6 +160,10 @@ export class IssueHelperEngine implements IIssueHelperEngine {
await doDeleteComment();
break;
}
case 'get-issue': {
await doGetIssue();
break;
}
case 'lock-issue': {
await doLockIssue();
break;
Expand Down
2 changes: 1 addition & 1 deletion src/issue/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type TAction =
| 'close-issues'
| 'find-comments'
| 'find-issues'
| 'get-issue'
| 'lock-issues'
| 'mark-assignees'
| 'mark-duplicate'
Expand Down
2 changes: 1 addition & 1 deletion web/docs/advanced.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit e348bdd

Please sign in to comment.