Skip to content

Commit 77e16f7

Browse files
authored
chore: update issue support create label (#198)
1 parent 26a4993 commit 77e16f7

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/helper/base.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ export async function doCreateIssue(
7474

7575
export async function doCreateLabel() {
7676
const name = core.getInput('label-name');
77-
const color = core.getInput('label-color') || 'ededed';
78-
const description = core.getInput('label-desc') || '';
77+
const color = core.getInput('label-color');
78+
const description = core.getInput('label-desc');
7979

8080
if (name) {
8181
await ICE.createLabel(name, color, description);

src/issue/issue.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ export class IssueCoreEngine implements IIssueCoreEngine {
130130

131131
public async createLabel(
132132
labelName: string,
133-
labelColor: string,
134-
labelDescription: string | undefined,
133+
labelColor: string = 'ededed',
134+
labelDescription: string = '',
135135
) {
136136
const { owner, repo, octokit } = this;
137137
await octokit.issues.createLabel({
@@ -318,11 +318,19 @@ export class IssueCoreEngine implements IIssueCoreEngine {
318318
state: baseState,
319319
} = issue;
320320

321-
const baseLabelsName = baseLabels.map(({ name }: any) => name);
322-
const baseAssignessName = baseAssigness?.map(({ login }: any) => login);
321+
const baseLabelsName = baseLabels.map(({ name }) => name);
322+
const baseAssignessName = baseAssigness?.map(({ login }) => login);
323323

324324
const newBody = body ? (mode === 'append' ? `${baseBody}\n${body}` : body) : baseBody;
325325

326+
if (labels && labels.length) {
327+
for (const label of labels) {
328+
if (baseLabelsName && baseLabelsName.length && baseLabelsName.indexOf(label) < 0) {
329+
await this.createLabel(label);
330+
}
331+
}
332+
}
333+
326334
await octokit.issues.update({
327335
owner,
328336
repo,

src/issue/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export interface IIssueCoreEngine {
8383
createIssueEmoji: (emoji: TEmoji[]) => Promise<void>;
8484
createLabel: (
8585
labelName: string,
86-
labelColor: string,
86+
labelColor: string | undefined,
8787
labelDescription: string | undefined,
8888
) => Promise<void>;
8989

0 commit comments

Comments
 (0)