File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 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,
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!')
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 }
You can’t perform that action at this time.
0 commit comments