[JIT] Add GitHub workflow for importing issues to triage project (#41056)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/41056

**Summary**
This commit adds a new GitHub workflow that automatically adds a card to
the "Need triage" section of the project board for tracking JIT triage
for each new issue that is opened and labelled "jit".

**Test Plan**
???

Test Plan: Imported from OSS

Differential Revision: D22444262

Pulled By: SplitInfinity

fbshipit-source-id: 4e7d384822bffb978468c303322f3e2c04062644
This commit is contained in:
Meghan Lele
2020-07-08 15:39:27 -07:00
committed by Facebook GitHub Bot
parent 6725c034b6
commit c7768e21b1

73
.github/workflows/jit_triage.yml vendored Normal file
View File

@ -0,0 +1,73 @@
name: jit-triage
on:
issues:
types: [opened, labeled]
jobs:
welcome:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
// Arguments available:
// - github: A pre-authenticated octokit/rest.js client
// - context: An object containing the context of the workflow run
// - core: A reference to the @actions/core package
// - io: A reference to the @actions/io package
// Check if issue has a JIT label.
const kJitLabel = "jit";
const hasJitLabel = context.issue.labels.filter(label => label.name == kJitLabel).length > 0;
if (!hasJitLabel) {
core.info("Issue " + context.issue.title + " does not have JIT label");
return;
}
// Get project column ID.
const kProjectName = "JIT Triage";
const kColumnName = "Need triage";
const kPyTorch = "pytorch";
// Query all projects in the repository.
// TODO: Support pagination once there are > 30 projects.
const projects = await github.projects.listForRepo({
owner: kPyTorch,
repo: kPyTorch,
});
// Filter out unwanted projects and get the ID for the JIT Triage project.
const filteredProjects = projects.filter(project => project.name == kProjectName);
if (filteredProjects.length != 1) {
core.setFailed("Unable to find a project named " + kProjectName);
return;
}
const projectId = filteredProjects[0].id;
// First, query all columns in the project.
// TODO: Support pagination once there are > 30 columns.
const columns = await github.projects.listColumns({
project_id: projectId,
});
// Filter out unwanted projects and get the ID for the Need triage column.
const filteredColumns = columns.filter(column => column.name == kColumnName);
if (filteredColumns != 1) {
core.setFailed("Unable to find a column named " + kColumnName);
return;
}
const columnId = filteredColumns[0].id;
// Create a project card for this new issue.
await octokit.projects.createCard({
column_id: columnId,
content_id: context.issue.id,
content_type: "Issue",
})