Skip to content

Commit

Permalink
Merge pull request #131 from thc202/auth-user
Browse files Browse the repository at this point in the history
fix: use authenticated user when checking issues
  • Loading branch information
psiinon authored Jul 3, 2023
2 parents 189c728 + dc5541d commit ed52f84
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ const actionCommon = {
if (issues.data.items.length === 0) {
create_new_issue = true;
} else {
const user = (await octokit.users.getAuthenticated()).data;
// Sometimes search API returns recently closed issue as an open issue
for (let i = 0; i < issues.data.items.length; i++) {
const issue = issues.data.items[i];
if (
issue["state"] === "open" &&
issue["user"]!["login"] === "github-actions[bot]"
issue["user"]!["login"] === user.login
) {
openIssue = issue;
break;
Expand All @@ -96,9 +97,7 @@ const actionCommon = {
let lastBotComment;
const lastCommentIndex = comments["data"].length - 1;
for (let i = lastCommentIndex; i >= 0; i--) {
if (
comments["data"][i]["user"]!["login"] === "github-actions[bot]"
) {
if (comments["data"][i]["user"]!["login"] === user.login) {
lastBotComment = comments["data"][i];
break;
}
Expand Down

0 comments on commit ed52f84

Please sign in to comment.