From 7109182f1e6d30caf602224c0bcafd02eb0e2bab Mon Sep 17 00:00:00 2001 From: SAI NIVEDH V Date: Sat, 2 Nov 2024 12:25:27 +0530 Subject: [PATCH] Update progress.yml --- .github/workflows/progress.yml | 89 ++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/.github/workflows/progress.yml b/.github/workflows/progress.yml index 48825edc..0f71f0b8 100644 --- a/.github/workflows/progress.yml +++ b/.github/workflows/progress.yml @@ -23,41 +23,68 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const twoWeeksAgo = new Date(process.env.two_weeks_ago); - - const issues = await github.rest.issues.listForRepo({ - owner: context.repo.owner, - repo: context.repo.name, - state: 'open', - since: twoWeeksAgo.toISOString() - }); - - console.log(`Found ${issues.data.length} issues from the past 2 weeks`); - - for (const issue of issues.data) { - // Skip if no assignees - if (!issue.assignees || issue.assignees.length === 0) { - console.log(`Skipping issue #${issue.number} - no assignees`); - continue; - } - - // Create mention string for all assignees - const assigneeMentions = issue.assignees - .map(assignee => `@${assignee.login}`) - .join(' '); + try { + const twoWeeksAgo = new Date(process.env.two_weeks_ago); - console.log(`Creating comment on issue #${issue.number} for ${assigneeMentions}`); + console.log(`Checking issues for repository: ${context.repo.owner}/${context.repo.name}`); - // Create and post comment - await github.rest.issues.createComment({ + const { data: issues } = await github.rest.issues.listForRepo({ owner: context.repo.owner, repo: context.repo.name, - issue_number: issue.number, - body: `Hey ${assigneeMentions}, can you share the progress of this project?` + state: 'open', + since: twoWeeksAgo.toISOString(), + per_page: 100 // Increase items per page }); - // Add small delay to avoid rate limiting - await new Promise(resolve => setTimeout(resolve, 1000)); + console.log(`Found ${issues.length} issues from the past 2 weeks`); + + if (issues.length === 0) { + console.log('No issues found in the specified time period.'); + return; + } + + for (const issue of issues) { + try { + // Skip if no assignees + if (!issue.assignees || issue.assignees.length === 0) { + console.log(`Skipping issue #${issue.number} - no assignees`); + continue; + } + + // Create mention string for all assignees + const assigneeMentions = issue.assignees + .map(assignee => `@${assignee.login}`) + .join(' '); + + console.log(`Creating comment on issue #${issue.number} for ${assigneeMentions}`); + + // Create and post comment + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.name, + issue_number: issue.number, + body: `Hey ${assigneeMentions}, can you share the progress of this project?` + }); + + // Add small delay to avoid rate limiting + await new Promise(resolve => setTimeout(resolve, 1000)); + } catch (issueError) { + console.error(`Error processing issue #${issue.number}:`, issueError); + } + } + + console.log('Finished processing all issues'); + + } catch (error) { + console.error('Error occurred:', error); + + if (error.status === 404) { + console.error('Repository not found or you don\'t have access to it.'); + console.error('Please check:'); + console.error('1. The repository name is correct'); + console.error('2. You have the necessary permissions'); + console.error('3. The repository exists'); + } + + throw error; } - - console.log('Finished processing all issues');