Skip to content

Commit

Permalink
Update progress.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
SaiNivedh26 authored Nov 2, 2024
1 parent 7538bde commit 7109182
Showing 1 changed file with 58 additions and 31 deletions.
89 changes: 58 additions & 31 deletions .github/workflows/progress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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');

0 comments on commit 7109182

Please sign in to comment.