-
Notifications
You must be signed in to change notification settings - Fork 741
Create add-unanswered-to-project.yml #12752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| 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 | ||
|
|
||
| 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) | ||
|
||
| 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 | ||
|
||
| const prs = await github.paginate( | ||
| github.rest.pulls.list, | ||
| { | ||
| owner, | ||
| repo, | ||
| state: 'open', | ||
| draft: false, | ||
| } | ||
| ); | ||
| for (const pr of prs) { | ||
GregoryComer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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}`); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"