-
Notifications
You must be signed in to change notification settings - Fork 118
90 lines (72 loc) · 3.32 KB
/
progress.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Issue Progress Check
on:
workflow_dispatch: # Only manual trigger
jobs:
check-issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get date from 2 weeks ago
id: date
run: |
echo "two_weeks_ago=$(date -d '2 weeks ago' '+%Y-%m-%d')" >> $GITHUB_ENV
- name: Query issues and create comments
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const twoWeeksAgo = new Date(process.env.two_weeks_ago);
console.log(`Checking issues for repository: ${context.repo.owner}/${context.repo.name}`);
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.name,
state: 'open',
since: twoWeeksAgo.toISOString(),
per_page: 100 // Increase items per page
});
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;
}