Skip to content

Commit a23b67b

Browse files
authored
Update workflow to ensure there is an area label (#15779)
1 parent 908fd21 commit a23b67b

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

.github/workflows/scripts/add-issue-labels.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
#!/usr/bin/env node
22

3+
/**
4+
* This script is used by a GitHub Actions workflow that handles 'issue opened' events.
5+
*
6+
* When an issue is opened it:
7+
*
8+
* - Reads the event payload from the issue event
9+
* - Ensures the issue has one of the QA labels (QA/dev-automation, QA/manual-test, QA/None). If it does not, then:
10+
* - If the issue has `kind/tech-debt` -> add `QA/None`
11+
* - Else if the issue has `ember` -> add `QA/manual-test`
12+
* - Otherwise -> add `QA/dev-automation`
13+
* - Adds the label `area/dashboard` if no other `area/*` labels are present
14+
*/
15+
316
const request = require('./request');
417

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

25+
const AREA_LABEL_PREFIX = 'area/';
26+
const DEFAULT_AREA_LABEL = 'area/dashboard';
27+
1228
// The event object
1329
const event = require(process.env.GITHUB_EVENT_PATH);
1430

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

2945
// Check we have a QA label
3046
if (!labels.includes(QA_DEV_AUTOMATION_LABEL) && !labels.includes(QA_MANUAL_TEST_LABEL) && !labels.includes(QA_NONE_LABEL)) {
31-
3247
// Add the appropriate QA label
3348
if (labels.includes(TECH_DEBT_LABEL)) {
3449
console.log(' Issue does not have a QA label, adding QA/None label (as issue is marked as tech-debt)');
@@ -47,6 +62,17 @@ async function processOpenAction() {
4762
didUpdateLabels = true;
4863
}
4964

65+
// If we don't have an `area/*` label, add the default one
66+
const hasAreaLabel = labels.find((label) => label.startsWith(AREA_LABEL_PREFIX));
67+
68+
if (!hasAreaLabel) {
69+
console.log(` Issue does not have an area label, adding default area label: ${ DEFAULT_AREA_LABEL }`);
70+
71+
labels.push(DEFAULT_AREA_LABEL);
72+
73+
didUpdateLabels = true;
74+
}
75+
5076
// Note: Built-in GitHub Project automation will add the 'To Triage' status to new issues
5177

5278
// Update the labels if we made a change

0 commit comments

Comments
 (0)