Skip to content

Add copy button for IDs, hostnames, FQDNs, paths etc in pop-up windows #14

Add copy button for IDs, hostnames, FQDNs, paths etc in pop-up windows

Add copy button for IDs, hostnames, FQDNs, paths etc in pop-up windows #14

name: Update Calculated Priority
on:
issues:
types: [opened, labeled, unlabeled, edited]
jobs:
update-priority:
runs-on: ubuntu-latest
steps:
- name: Update CalculatedPriority field
uses: actions/github-script@v7
with:
github-token: ${{ secrets.YDBOT_TOKEN }}
script: |
const labelWeights = {
"prio/high": 1000,
"prio/medium": 500,
"prio/low": 100
};
const issue = context.payload.issue;
const labels = issue.labels.map(l => l.name);
const basePriority = Math.min(...labels.map(l => labelWeights[l] || 10), 1000);
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;
const org = "ydb-platform";
const result = await github.graphql(`
query($org: String!, $number: Int!) {
organization(login: $org) {
projectV2(number: $number) {
id
fields(first: 50) {
nodes {
... on ProjectV2Field {
id
name
}
}
}
items(first: 100) {
nodes {
id
content {
... on Issue {
id
number
}
}
}
}
}
}
}
`, { 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);
if (!item) {
console.log(`Issue #${issue.number} not found in project.`);
return;
}
await github.graphql(`
mutation($input: UpdateProjectV2ItemFieldValueInput!) {
updateProjectV2ItemFieldValue(input: $input) {
projectV2Item {
id
}
}
}
`, {
input: {
projectId: project.id,
itemId: item.id,
fieldId: field.id,
value: { number: finalScore }
}
});
console.log(`Updated CalculatedPriority of issue #${issue.number} to ${finalScore}`);