Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/add-unanswered-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Add Unanswered PRs and Issues to PyTorch Org Project 136
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about renaming to "Add External PRs and Issues...", since we're not filtering by unanswered yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, considering the current queries look at just open PRs and Issues. I could change it to "Add Open External Contributor PRs and Issues to PyTorch Org Project 136"


on:
schedule:
- cron: '0 * * * *' # every hour, on the hour (UTC)
workflow_dispatch: # allows manual runs too

jobs:
add_to_project:
runs-on: ubuntu-latest
steps:
- name: Query open PRs and issues and add to org project
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PYTORCH_PROJECT_PAT }}
script: |
const projectId = "PVT_kwDOAUB9vs4A_PUL"; // PyTorch org project 136
const owner = 'pytorch';
const repo = 'executorch';

async function addItem(contentId, type, number) {
try {
await github.graphql(`
mutation {
addProjectV2ItemById(input: {projectId: "${projectId}", contentId: "${contentId}"}) {
item { id }
}
}
`);
console.log(`Added ${type} #${number} to project`);
} catch (error) {
console.log(`Error adding ${type} #${number}: ${error.message}`);
}
}

try {
// Add open issues (not PRs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it's only adding issues. Can we add both PRs and issues?

const issues = await github.paginate(
github.rest.issues.listForRepo,
{
owner,
repo,
state: 'open',
filter: 'all'
}
);
for (const issue of issues) {
if (!issue.pull_request) {
await addItem(issue.node_id, 'issue', issue.number);
}
}

// Add open, non-draft PRs with NO approved reviews
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GregoryComer this block covers PRs as well

const prs = await github.paginate(
github.rest.pulls.list,
{
owner,
repo,
state: 'open',
draft: false,
}
);
for (const pr of prs) {
const reviews = await github.rest.pulls.listReviews({
owner,
repo,
pull_number: pr.number
});
const approved = reviews.data.some(r => r.state === 'APPROVED');
if (!approved) {
await addItem(pr.node_id, 'pr', pr.number);
}
}
} catch (error) {
core.setFailed(`Workflow failed: ${error.message}`);
}
Loading