1- name : Add Unanswered PRs and Issues to PyTorch Project 133
1+ name : Add Unanswered PRs and Issues to PyTorch Org Project 136
22
33on :
44 schedule :
5- - cron : ' 0 * * * *'
6- workflow_dispatch :
5+ - cron : ' 0 * * * *' # every hour, on the hour (UTC)
6+ workflow_dispatch : # allows manual runs too
77
88jobs :
99 add_to_project :
1010 runs-on : ubuntu-latest
1111 steps :
12- - name : Query unanswered PRs and issues and add to project
12+ - name : Query open PRs and issues and add to org project
1313 uses : actions/github-script@v7
1414 with :
15- github-token : ${{ secrets.GITHUB_TOKEN }}
15+ github-token : ${{ secrets.PYTORCH_PROJECT_PAT }}
1616 script : |
17- const projectId = "PVT_kwDOAUB9vs4A-j69";
17+ const projectId = "PVT_kwDOAUB9vs4A_PUL"; // PyTorch org project 136
18+ const owner = 'pytorch';
19+ const repo = 'executorch';
1820
19- async function addItem(contentId) {
21+ async function addItem(contentId, type, number ) {
2022 try {
2123 await github.graphql(`
2224 mutation {
@@ -25,52 +27,48 @@ jobs:
2527 }
2628 }
2729 `);
28- console.log(`Added item with contentId: ${contentId} `);
30+ console.log(`Added ${type} #${number} to project `);
2931 } catch (error) {
30- console.log(`Error adding item ${contentId }: ${error.message}`);
32+ console.log(`Error adding ${type} #${number }: ${error.message}`);
3133 }
3234 }
3335
3436 try {
35- // Get unanswered PRs: open, not draft, not approved
37+ // Add open issues (not PRs)
38+ const issues = await github.paginate(
39+ github.rest.issues.listForRepo,
40+ {
41+ owner,
42+ repo,
43+ state: 'open',
44+ filter: 'all'
45+ }
46+ );
47+ for (const issue of issues) {
48+ if (!issue.pull_request) {
49+ await addItem(issue.node_id, 'issue', issue.number);
50+ }
51+ }
52+
53+ // Add open, non-draft PRs with NO approved reviews
3654 const prs = await github.paginate(
3755 github.rest.pulls.list,
3856 {
39- owner: 'pytorch' ,
40- repo: 'executorch' ,
57+ owner,
58+ repo,
4159 state: 'open',
4260 draft: false,
4361 }
4462 );
45-
4663 for (const pr of prs) {
4764 const reviews = await github.rest.pulls.listReviews({
48- owner: 'pytorch' ,
49- repo: 'executorch' ,
65+ owner,
66+ repo,
5067 pull_number: pr.number
5168 });
5269 const approved = reviews.data.some(r => r.state === 'APPROVED');
5370 if (!approved) {
54- console.log(`Adding unanswered PR #${pr.number}`);
55- await addItem(pr.node_id);
56- }
57- }
58-
59- // Get open issues (not PRs)
60- const issues = await github.paginate(
61- github.rest.issues.listForRepo,
62- {
63- owner: 'pytorch',
64- repo: 'executorch',
65- state: 'open',
66- filter: 'all'
67- }
68- );
69-
70- for (const issue of issues) {
71- if (!issue.pull_request) {
72- console.log(`Adding open issue #${issue.number}`);
73- await addItem(issue.node_id);
71+ await addItem(pr.node_id, 'pr', pr.number);
7472 }
7573 }
7674 } catch (error) {
0 commit comments