Skip to content
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: 15 additions & 0 deletions .github/workflows/add-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Auto-add to GitHub Project

on:
issues:
types: [opened]

jobs:
auto-add:
runs-on: ubuntu-latest
steps:
- name: Add to project
uses: github/add-to-project@v1
with:
github-token: ${{ secrets.YDBOT_TOKEN }}
project-url: https://github.com/orgs/ydb-platform/projects/24
23 changes: 19 additions & 4 deletions .github/workflows/priority-score.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:

const createdAt = new Date(issue.created_at);
const daysOld = Math.floor((Date.now() - createdAt.getTime()) / (1000 * 60 * 60 * 24));

const finalScore = basePriority + daysOld;

const projectNumber = 24;
Expand All @@ -48,9 +47,14 @@ jobs:
nodes {
id
content {
__typename
... on Issue {
id
number
repository {
name
owner { login }
}
}
}
}
Expand All @@ -61,15 +65,26 @@ jobs:
`, { org, number: projectNumber });

const project = result.organization.projectV2;

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

const item = project.items.nodes.find(n => n.content?.number === issue.number);
const issueNumber = issue.number;
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;

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
);

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

Expand All @@ -90,4 +105,4 @@ jobs:
}
});

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