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 25
25
26
26
const createdAt = new Date(issue.created_at);
27
27
const daysOld = Math.floor((Date.now() - createdAt.getTime()) / (1000 * 60 * 60 * 24));
28
-
29
28
const finalScore = basePriority + daysOld;
30
29
31
30
const projectNumber = 24;
48
47
nodes {
49
48
id
50
49
content {
50
+ __typename
51
51
... on Issue {
52
52
id
53
53
number
54
+ repository {
55
+ name
56
+ owner { login }
57
+ }
54
58
}
55
59
}
56
60
}
@@ -61,15 +65,26 @@ jobs:
61
65
`, { org, number: projectNumber });
62
66
63
67
const project = result.organization.projectV2;
68
+
64
69
const field = project.fields.nodes.find(f => f.name === "CalculatedPriority");
65
70
if (!field) {
66
71
core.setFailed("Field 'CalculatedPriority' not found.");
67
72
return;
68
73
}
69
74
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
+
71
86
if (!item) {
72
- console.log(`Issue #${issue.number } not found in project.`);
87
+ console.log(`Issue #${issueNumber } not found in project (repo=${repoName}) .`);
73
88
return;
74
89
}
75
90
90
105
}
91
106
});
92
107
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