Skip to content
Merged
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
28 changes: 27 additions & 1 deletion .github/workflows/scripts/add-issue-labels.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/usr/bin/env node

/**
* This script is used by a GitHub Actions workflow that handles 'issue opened' events.
*
* When an issue is opened it:
*
* - Reads the event payload from the issue event
* - Ensures the issue has one of the QA labels (QA/dev-automation, QA/manual-test, QA/None). If it does not, then:
* - If the issue has `kind/tech-debt` -> add `QA/None`
* - Else if the issue has `ember` -> add `QA/manual-test`
* - Otherwise -> add `QA/dev-automation`
* - Adds the label `area/dashboard` if no other `area/*` labels are present
*/

const request = require('./request');

const QA_DEV_AUTOMATION_LABEL = 'QA/dev-automation';
Expand All @@ -9,6 +22,9 @@ const QA_NONE_LABEL = 'QA/None';
const EMBER_LABEL = 'ember';
const TECH_DEBT_LABEL = 'kind/tech-debt';

const AREA_LABEL_PREFIX = 'area/';
const DEFAULT_AREA_LABEL = 'area/dashboard';

// The event object
const event = require(process.env.GITHUB_EVENT_PATH);

Expand All @@ -28,7 +44,6 @@ async function processOpenAction() {

// Check we have a QA label
if (!labels.includes(QA_DEV_AUTOMATION_LABEL) && !labels.includes(QA_MANUAL_TEST_LABEL) && !labels.includes(QA_NONE_LABEL)) {

// Add the appropriate QA label
if (labels.includes(TECH_DEBT_LABEL)) {
console.log(' Issue does not have a QA label, adding QA/None label (as issue is marked as tech-debt)');
Expand All @@ -47,6 +62,17 @@ async function processOpenAction() {
didUpdateLabels = true;
}

// If we don't have an `area/*` label, add the default one
const hasAreaLabel = labels.find((label) => label.startsWith(AREA_LABEL_PREFIX));

if (!hasAreaLabel) {
console.log(` Issue does not have an area label, adding default area label: ${ DEFAULT_AREA_LABEL }`);

labels.push(DEFAULT_AREA_LABEL);

didUpdateLabels = true;
}

// Note: Built-in GitHub Project automation will add the 'To Triage' status to new issues

// Update the labels if we made a change
Expand Down
Loading