Skip to content

Commit

Permalink
Merge pull request #137 from thc202/bot-fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
kingthorin authored Jul 4, 2023
2 parents 56a3ba9 + 6c9c4db commit 59266c3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ const actionCommon = {
if (issues.data.items.length === 0) {
create_new_issue = true;
} else {
const user = (await octokit.users.getAuthenticated()).data;
let login = "github-actions[bot]";
try {
login = (await octokit.users.getAuthenticated()).data.login;
} catch (e) {
console.log(`Using ${login} to serch for issues.`);
}
// 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"] === user.login
) {
if (issue["state"] === "open" && issue["user"]!["login"] === login) {
openIssue = issue;
break;
}
Expand All @@ -97,7 +99,7 @@ const actionCommon = {
let lastBotComment;
const lastCommentIndex = comments["data"].length - 1;
for (let i = lastCommentIndex; i >= 0; i--) {
if (comments["data"][i]["user"]!["login"] === user.login) {
if (comments["data"][i]["user"]!["login"] === login) {
lastBotComment = comments["data"][i];
break;
}
Expand Down

0 comments on commit 59266c3

Please sign in to comment.