Skip to content

Commit 1a2ade4

Browse files
authored
fix(Automation): more automation, auto add to project (#2376)
1 parent 928fba4 commit 1a2ade4

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

.github/workflows/add-to-project.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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

.github/workflows/priority-score.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
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;
@@ -48,9 +47,14 @@ jobs:
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
@@ -90,4 +105,4 @@ jobs:
90105
}
91106
});
92107
93-
console.log(`Updated CalculatedPriority of issue #${issue.number} to ${finalScore}`);
108+
console.log(`Updated CalculatedPriority of issue #${issueNumber} to ${finalScore}`);

0 commit comments

Comments
 (0)