Skip to content

fix(Automation): even more automation #2380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/workflows/add-to-project.yml

This file was deleted.

88 changes: 56 additions & 32 deletions .github/workflows/priority-score.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ jobs:

const projectNumber = 24;
const org = "ydb-platform";
const issueNumber = issue.number;
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;

const result = await github.graphql(`
const projectQuery = await github.graphql(`
query($org: String!, $number: Int!) {
organization(login: $org) {
projectV2(number: $number) {
Expand All @@ -43,51 +46,72 @@ jobs:
}
}
}
items(first: 100) {
nodes {
id
content {
__typename
... on Issue {
id
number
repository {
name
owner { login }
}
}
}
}
}
}
}
}
`, { org, number: projectNumber });

const project = result.organization.projectV2;

const field = project.fields.nodes.find(f => f.name === "CalculatedPriority");
const projectId = projectQuery.organization.projectV2.id;
const field = projectQuery.organization.projectV2.fields.nodes.find(f => f.name === "CalculatedPriority");
if (!field) {
core.setFailed("Field 'CalculatedPriority' not found.");
return;
}
const fieldId = field.id;

const issueNumber = issue.number;
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;
// Now paginate to find the matching item
let item = null;
let cursor = null;
let hasNextPage = true;

const item = project.items.nodes.find(n =>
n.content?.__typename === "Issue" &&
n.content?.number === issueNumber &&
n.content?.repository?.name === repoName &&
n.content?.repository?.owner?.login === repoOwner
);
while (hasNextPage && !item) {
const response = await github.graphql(`
query($org: String!, $number: Int!, $after: String) {
organization(login: $org) {
projectV2(number: $number) {
items(first: 100, after: $after) {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
content {
__typename
... on Issue {
number
repository {
name
owner { login }
}
}
}
}
}
}
}
}
`, { org, number: projectNumber, after: cursor });

const items = response.organization.projectV2.items.nodes;

item = items.find(n =>
n.content?.__typename === "Issue" &&
n.content?.number === issueNumber &&
n.content?.repository?.name === repoName &&
n.content?.repository?.owner?.login === repoOwner
);

hasNextPage = response.organization.projectV2.items.pageInfo.hasNextPage;
cursor = response.organization.projectV2.items.pageInfo.endCursor;
}

if (!item) {
console.log(`Issue #${issueNumber} not found in project (repo=${repoName}).`);
return;
}

// Update field
await github.graphql(`
mutation($input: UpdateProjectV2ItemFieldValueInput!) {
updateProjectV2ItemFieldValue(input: $input) {
Expand All @@ -98,11 +122,11 @@ jobs:
}
`, {
input: {
projectId: project.id,
projectId,
itemId: item.id,
fieldId: field.id,
fieldId,
value: { number: finalScore }
}
});

console.log(`Updated CalculatedPriority of issue #${issueNumber} to ${finalScore}`);
console.log(`Updated CalculatedPriority of issue #${issueNumber} to ${finalScore}`);
Loading