Skip to content

Add Open External Contributor PRs and Issues to PyTorch Org Project 136 #117

Add Open External Contributor PRs and Issues to PyTorch Org Project 136

Add Open External Contributor PRs and Issues to PyTorch Org Project 136 #117

name: Add Open External Contributor PRs and Issues to PyTorch Org Project 136
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
jobs:
add_to_project:
runs-on: ubuntu-latest
steps:
- name: Add open issues and open, non-draft PRs to org project (excluding certain authors)
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';
// List of authors to exclude
const excludedAuthors = new Set([
"nil-is-all", "cbilgin", "KimishPatel", "psiddh", "digantdesai", "SS-JIA", "ahmtox", "mcr229", "shoumikhin",
"manuelcandales", "metascroy", "cccclai", "rohansjoshi", "kirklandsign", "abhinaykukkadapu", "JacobSzwejbka",
"Conarnar", "lucylq", "larryliu0820", "BujSet", "Gasoonjia", "Juntian777", "guangy10", "jackzhxng",
"GregoryComer", "leafs1", "swolchok", "mergennachin", "tarun292", "byjlw", "jathu", "Jack-Khuu", "georgehong",
"zhenyan-zhang-meta", "silverguo", "dbort", "jorgep31415", "huydhn", "mcremon-meta", "trivedivivek", "angelayi",
"helunwencser", "hsharma35", "zhxchen17", "iseeyuan", "svekars", "nathanaelsee", "dulinriley", "jerryzh168",
"cmodi-meta", "bigfootjon", "sxu", "ydwu4", "Riandy", "tugsbayasgalan", "bsoyluoglu", "yangw-dev", "YIWENX14",
"namanahuja", "yushangdi", "limintang", "pianpwk", "viveknayakatmeta", "andreanicastro", "JakeStevens",
"gmagogsfm", "zonglinpeng", "eigen-k", "derekxu", "salilsdesai", "skrtskrtfb", "pssrawat", "r-barnes", "pytorchbot",
"pytorchmergebot", "pytorchupdatebot", "facebook-github-bot", "Erik-Lundell", "zingo", "AdrianLundell",
"oscarandersson8218", "per", "Sebastian-Larsson", "SaoirseARM", "robell", "mansnils", "martinlsm", "freddan80",
"YufengShi-dudu", "tom-arm", "perheld", "Jerry-Ge", "gggekov", "fumchin", "wwwind", "haowhsu-quic", "shewu-quic",
"winskuo-quic", "chunit-quic", "DannyYuyang-quic", "chuntl", "cymbalrush", "DenisVieriu97", "billmguo",
"StrycekSimon", "jirioc", "robert-kalmar", "skywall", "neuropilot-captain"
]);
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) {
if (error.message && error.message.includes("A project item already exists for this content")) {
// Ignore if already exists
console.log(`${type} #${number} already in project`);
} else {
console.log(`Error adding ${type} #${number}: ${error.message}`);
}
}
}
try {
// Add open issues (not PRs) and exclude by author
const issues = await github.paginate(
github.rest.issues.listForRepo,
{
owner,
repo,
state: 'open',
filter: 'all'
}
);
for (const issue of issues) {
if (!issue.pull_request && !excludedAuthors.has(issue.user.login)) {
await addItem(issue.node_id, 'issue', issue.number);
}
}
// Add open, non-draft PRs (regardless of review state), exclude by author
const prs = await github.paginate(
github.rest.pulls.list,
{
owner,
repo,
state: 'open',
draft: false,
}
);
for (const pr of prs) {
if (!excludedAuthors.has(pr.user.login)) {
await addItem(pr.node_id, 'pr', pr.number);
}
}
} catch (error) {
core.setFailed(`Workflow failed: ${error.message}`);
}