Auto Assign Issues (Org-wide) #757
This file contains hidden or 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: Auto Assign Issues (Org-wide) | |
| on: | |
| schedule: | |
| - cron: '*/15 * * * *' # Every 15 minutes | |
| workflow_dispatch: # Manual trigger | |
| jobs: | |
| assign-issues: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Auto-assign unassigned issues across all repos | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.ORG_PAT }} | |
| script: | | |
| const org = 'CodingWithCalvin'; | |
| const assignee = 'CalvinAllen'; | |
| // Get all repos in org | |
| const repos = await github.paginate(github.rest.repos.listForOrg, { | |
| org, | |
| type: 'all' | |
| }); | |
| console.log(`Found ${repos.length} repositories`); | |
| for (const repo of repos) { | |
| try { | |
| // Get open, unassigned issues | |
| const issues = await github.rest.issues.listForRepo({ | |
| owner: org, | |
| repo: repo.name, | |
| state: 'open', | |
| assignee: 'none' | |
| }); | |
| for (const issue of issues.data) { | |
| // Skip pull requests (they show up in issues API) | |
| if (issue.pull_request) { | |
| continue; | |
| } | |
| await github.rest.issues.addAssignees({ | |
| owner: org, | |
| repo: repo.name, | |
| issue_number: issue.number, | |
| assignees: [assignee] | |
| }); | |
| console.log(`Assigned ${repo.name}#${issue.number}: ${issue.title}`); | |
| } | |
| } catch (error) { | |
| console.log(`Error processing ${repo.name}: ${error.message}`); | |
| } | |
| } | |
| console.log('Done!'); |