From 5cd232b065cb73f40f0d610073c1ccfaa1d67015 Mon Sep 17 00:00:00 2001 From: csehatt741 Date: Sun, 23 Feb 2025 08:44:45 +0100 Subject: [PATCH 1/2] Issue fetched via API --- .github/workflows/auto-assign.yaml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/auto-assign.yaml b/.github/workflows/auto-assign.yaml index a4268bc6..841271c1 100644 --- a/.github/workflows/auto-assign.yaml +++ b/.github/workflows/auto-assign.yaml @@ -15,32 +15,31 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const comment = context.payload.comment; - const issue = context.issue; const owner = 'keyshade-xyz'; const repo = 'keyshade'; const userMaxConcurrentIssueCount = process.env.USER_MAX_CONCURRENT_ISSUE_COUNT || 5; - async function listIssueEvents(issue) { - const allEvents = []; + async function listIssueEvents(issueNumber) { + const events = []; let page = 1; let hasNextPage = true; while (hasNextPage) { - const issuesResponse = await github.rest.issues.listEventsForTimeline({ + const eventsResponse = await github.rest.issues.listEventsForTimeline({ owner, repo, - issue_number: issue.number, + issue_number: issueNumber, per_page: 100, page }); - allEvents.push(...issuesResponse.data); + events.push(...eventsResponse.data); - hasNextPage = issuesResponse.headers.link && issuesResponse.headers.link.includes('rel="next"'); + hasNextPage = eventsResponse.headers.link && eventsResponse.headers.link.includes('rel="next"'); page++; } - return allEvents; + return events; } async function listUserOpenIssuesWithoutActivePullRequest(user) { @@ -55,7 +54,7 @@ jobs: }); for (const issue of userOpenIssues) { - const events = await listIssueEvents(issue); + const events = await listIssueEvents(issue.number); const userPullRequestIssues = events .filter(event => event.event === 'cross-referenced') .map(event => event.source.issue) @@ -117,6 +116,12 @@ jobs: } if (comment.body.startsWith('/attempt')) { + const issue = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + if (!issue.assignee) { const userActiveIssues = await listUserOpenIssuesWithoutActivePullRequest(comment.user); From 00978f93169719b663fd35e624c76ef646face40 Mon Sep 17 00:00:00 2001 From: csehatt741 Date: Sun, 23 Feb 2025 08:56:20 +0100 Subject: [PATCH 2/2] context logged --- .github/workflows/auto-assign.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/auto-assign.yaml b/.github/workflows/auto-assign.yaml index 841271c1..5d2ab078 100644 --- a/.github/workflows/auto-assign.yaml +++ b/.github/workflows/auto-assign.yaml @@ -19,6 +19,8 @@ jobs: const repo = 'keyshade'; const userMaxConcurrentIssueCount = process.env.USER_MAX_CONCURRENT_ISSUE_COUNT || 5; + console.dir(context); + async function listIssueEvents(issueNumber) { const events = []; let page = 1;