Skip to content

Commit bd4baa0

Browse files
committed
Update CI check
1 parent 53eb670 commit bd4baa0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/check-pr-changelog.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
script: |
2828
const yaml = require('js-yaml');
2929
const fs = require('fs');
30+
const execSync = require('child_process').execSync;
3031
3132
const prDescription = await github.rest.pulls.get({
3233
owner: context.repo.owner,
@@ -72,6 +73,18 @@ jobs:
7273
console.error(`PR changelog has invalid type: ${changelog.type}\nExpected one, or more of: ${validTypeValues}`)
7374
}
7475
76+
let isProjectsValid = false;
77+
// .filter(Boolean) is a trick that removes empty values from the array (see https://michaeluloth.com/javascript-filter-boolean/)
78+
const validProjectsValues = execSync("ls */CHANGELOG* | cut -d/ -f1").toString().split('\n').filter(Boolean)
79+
if (Array.isArray(changelog.projects) && !!changelog.projects) {
80+
isProjectsValid = changelog.projects.every(value => validProjectsValues.includes(value));
81+
} else {
82+
isProjectsValid = validProjectsValue.includes(changelog.projects);
83+
}
84+
if (!isProjectsValid) {
85+
console.error(`PR changelog has invalid project: ${changelog.projects}\nExpected one, or more of: ${validProjectsValues}`)
86+
}
87+
7588
let isDescriptionValid = true;
7689
if (changelog.description.trim() === '<insert-changelog-description-here>') {
7790
console.error('PR changelog description has not been updated!')
@@ -81,7 +94,7 @@ jobs:
8194
isDescriptionValid = false;
8295
}
8396
84-
if (!isCompatibilityValid || !isTypeValid || !isDescriptionValid) {
97+
if (!isCompatibilityValid || !isTypeValid || !isProjectsValid || !isDescriptionValid) {
8598
console.error('Failed PR changelog checks!');
8699
process.exit(1);
87100
}

0 commit comments

Comments
 (0)