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
19 changes: 19 additions & 0 deletions .github/workflows/project-prioritization-bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: P1 Bug Prioritization
on:
issues:
types:
- labeled

jobs:
prioritize:
if: github.repository == 'aws/aws-cdk' && contains(github.event.issue.labels.*.name, 'bug') && contains(github.event.issue.labels.*.name, 'p1')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Add P1 Bug to project
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
script: |
const script = require('./scripts/prioritization/assign-bug-priority.js')
await script({github, context})
55 changes: 55 additions & 0 deletions scripts/prioritization/assign-bug-priority.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { PRIORITIES, LABELS, STATUS, ...PROJECT_CONFIG } = require('./project-config');
const {
updateProjectField,
addItemToProject,
fetchProjectFields,
} = require('./project-api');

module.exports = async ({ github, context }) => {
async function addToProject(issue) {
console.log(`Processing issue #${issue.number}...`);

// Get project fields
const projectFields = await fetchProjectFields({
github,
org: PROJECT_CONFIG.org,
number: PROJECT_CONFIG.projectNumber
});
const priorityField = projectFields.organization.projectV2.fields.nodes.find(
(field) => field.id === PROJECT_CONFIG.priorityFieldId
);

const addResult = await addItemToProject({
github,
projectId: PROJECT_CONFIG.projectId,
contentId: issue.node_id,
});

const itemId = addResult.addProjectV2ItemById.item.id;

const priorityR6OptionId = priorityField.options.find(
(option) => option.name === PRIORITIES.R6
)?.id;

if (!priorityR6OptionId) {
throw new Error(`Cannot find Id of the R6 priority option.
Found: ${priorityField.options.map(op => op.name)}`);
}

await updateProjectField({
github,
projectId: PROJECT_CONFIG.projectId,
itemId: itemId,
fieldId: PROJECT_CONFIG.priorityFieldId,
value: priorityR6OptionId,
});
}

const issue = context.payload.issue;
const labels = issue.labels.map((l) => l.name);
if (labels.includes(LABELS.P1) && labels.includes(LABELS.BUG)) {
await addToProject(issue);
} else {
// do nothing
}
};
7 changes: 5 additions & 2 deletions scripts/prioritization/project-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ const LABELS = {
MAINTAINER_REVIEW: 'pr/needs-maintainer-review',
COMMUNITY_REVIEW: 'pr/needs-community-review',
CLARIFICATION_REQUESTED: 'pr/reviewer-clarification-requested',
EXEMPTION_REQUESTED: 'pr-linter/exemption-requested'
EXEMPTION_REQUESTED: 'pr-linter/exemption-requested',
P1: 'p1',
BUG: 'bug'
};

const PRIORITIES = {
R1: '🚨 R1',
R2: '🔥 R2',
R3: '🎯 R3',
R4: '💭 R4',
R5: '📆 R5'
R5: '📆 R5',
R6: '🐛 R6'
};

const STATUS = {
Expand Down