Skip to content

Commit 0f69269

Browse files
committed
if an issue is tagged with good first issue it should automatically go to the new contributors project
1 parent 6fb42ef commit 0f69269

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Add Good First Issues to Project
2+
3+
on:
4+
issues:
5+
types:
6+
- labeled
7+
8+
jobs:
9+
add-to-project:
10+
name: Add issue to project
11+
if: github.event.label.name == 'good first issue'
12+
runs-on: ubuntu-latest
13+
permissions:
14+
# Need read access to issues to get issue details
15+
issues: read
16+
# Need write access to organization projects to add issues
17+
organization-projects: write
18+
steps:
19+
- name: Add issue to project
20+
uses: actions/github-script@v7
21+
with:
22+
github-token: ${{ secrets.ET_GH_TOKEN_ISSUES_PROJECTS }}
23+
script: |
24+
const core = require('@actions/core');
25+
26+
try {
27+
// First get the project ID
28+
const projectQuery = `
29+
query {
30+
organization(login: "pytorch") {
31+
projectV2(number: 102) {
32+
id
33+
}
34+
}
35+
}
36+
`;
37+
38+
const projectResult = await github.graphql(projectQuery);
39+
const projectId = projectResult.organization.projectV2.id;
40+
41+
// Add the issue to the project
42+
const addToProjectMutation = `
43+
mutation($projectId: ID!, $contentId: ID!) {
44+
addProjectV2ItemById(input: {
45+
projectId: $projectId
46+
contentId: $contentId
47+
}) {
48+
item {
49+
id
50+
}
51+
}
52+
}
53+
`;
54+
55+
await github.graphql(addToProjectMutation, {
56+
projectId: projectId,
57+
contentId: context.payload.issue.node_id
58+
});
59+
60+
console.log(`Successfully added issue #${context.issue.number} to project`);
61+
} catch (error) {
62+
core.setFailed(`Failed to add issue to project: ${error.message}`);
63+
}

0 commit comments

Comments
 (0)