Issue Progress Check #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | | |
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(' '); | |
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)); | |
} | |
console.log('Finished processing all issues'); |