File tree Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change 1+ name : Auto-add to GitHub Project
2+
3+ on :
4+ issues :
5+ types : [opened]
6+
7+ jobs :
8+ auto-add :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Add to project
12+ uses : github/add-to-project@v1
13+ with :
14+ github-token : ${{ secrets.YDBOT_TOKEN }}
15+ project-url : https://github.com/orgs/ydb-platform/projects/24
Original file line number Diff line number Diff line change 2525
2626 const createdAt = new Date(issue.created_at);
2727 const daysOld = Math.floor((Date.now() - createdAt.getTime()) / (1000 * 60 * 60 * 24));
28-
2928 const finalScore = basePriority + daysOld;
3029
3130 const projectNumber = 24;
4847 nodes {
4948 id
5049 content {
50+ __typename
5151 ... on Issue {
5252 id
5353 number
54+ repository {
55+ name
56+ owner { login }
57+ }
5458 }
5559 }
5660 }
@@ -61,15 +65,26 @@ jobs:
6165 `, { org, number: projectNumber });
6266
6367 const project = result.organization.projectV2;
68+
6469 const field = project.fields.nodes.find(f => f.name === "CalculatedPriority");
6570 if (!field) {
6671 core.setFailed("Field 'CalculatedPriority' not found.");
6772 return;
6873 }
6974
70- const item = project.items.nodes.find(n => n.content?.number === issue.number);
75+ const issueNumber = issue.number;
76+ const repoName = context.repo.repo;
77+ const repoOwner = context.repo.owner;
78+
79+ const item = project.items.nodes.find(n =>
80+ n.content?.__typename === "Issue" &&
81+ n.content?.number === issueNumber &&
82+ n.content?.repository?.name === repoName &&
83+ n.content?.repository?.owner?.login === repoOwner
84+ );
85+
7186 if (!item) {
72- console.log(`Issue #${issue.number } not found in project.`);
87+ console.log(`Issue #${issueNumber } not found in project (repo=${repoName}) .`);
7388 return;
7489 }
7590
90105 }
91106 });
92107
93- console.log(`Updated CalculatedPriority of issue #${issue.number } to ${finalScore}`);
108+ console.log(`Updated CalculatedPriority of issue #${issueNumber } to ${finalScore}`);
You can’t perform that action at this time.
0 commit comments