Skip to content

Commit a5f3caa

Browse files
Merge pull request #10 from aws-github-ops/emptyFix
fix: submitting an empty array for labels or assignees is now accepted
2 parents 59f3546 + 1d73ce9 commit a5f3caa

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

lib/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28001,11 +28001,15 @@ class GithubApi {
2800128001
}
2800228002
setIssueAssignees(assignees) {
2800328003
return __awaiter(this, void 0, void 0, function* () {
28004+
if (!assignees.length)
28005+
return;
2800428006
yield this.octokit.issues.addAssignees(Object.assign(Object.assign({}, this.repo), { issue_number: this.issueNumber, assignees }));
2800528007
});
2800628008
}
2800728009
setIssueLabels(labels) {
2800828010
return __awaiter(this, void 0, void 0, function* () {
28011+
if (!labels.length)
28012+
return;
2800928013
yield this.octokit.issues.addLabels(Object.assign(Object.assign({}, this.repo), { issue_number: this.issueNumber, labels }));
2801028014
});
2801128015
}
@@ -28074,8 +28078,10 @@ function run() {
2807428078
console.log("Keywords not included in this issue");
2807528079
}
2807628080
else {
28077-
github.setIssueAssignees(winningAreaData.assignees);
28078-
github.setIssueLabels(winningAreaData.labels);
28081+
if (winningAreaData.assignees)
28082+
github.setIssueAssignees(winningAreaData.assignees);
28083+
if (winningAreaData.labels)
28084+
github.setIssueLabels(winningAreaData.labels);
2807928085
core.setOutput("labeled", true.toString());
2808028086
core.setOutput("assigned", true.toString());
2808128087
}

src/github.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class GithubApi {
2626
}
2727

2828
public async setIssueAssignees(assignees: string[]) {
29+
if(!assignees.length) return;
2930
await this.octokit.issues.addAssignees({
3031
...this.repo,
3132
issue_number: this.issueNumber,
@@ -34,6 +35,7 @@ export class GithubApi {
3435
}
3536

3637
public async setIssueLabels(labels: string[]) {
38+
if(!labels.length) return;
3739
await this.octokit.issues.addLabels({
3840
...this.repo,
3941
issue_number: this.issueNumber,

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ async function run() {
1515
if (winningAreaData.area === '') {
1616
console.log("Keywords not included in this issue");
1717
} else {
18-
github.setIssueAssignees(winningAreaData.assignees);
19-
github.setIssueLabels(winningAreaData.labels);
18+
if(winningAreaData.assignees) github.setIssueAssignees(winningAreaData.assignees);
19+
if(winningAreaData.labels) github.setIssueLabels(winningAreaData.labels);
2020
core.setOutput("labeled", true.toString());
2121
core.setOutput("assigned", true.toString());
2222
}

src/issue.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import * as core from "@actions/core";
22
import levenshtein from 'js-levenshtein';
33

4-
export interface IParameter {
4+
export interface IParameter extends IDefaultArea {
55
area: string;
66
keywords: string[];
7-
labels: string[];
8-
assignees: string[];
7+
}
8+
9+
export interface IDefaultArea {
10+
labels?: string[];
11+
assignees?: string[];
912
}
1013

1114
export class Issue {

0 commit comments

Comments
 (0)