mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-17 05:02:23 +08:00
Check for "do not merge" and required pr-log labels
This commit is contained in:
parent
7bb724f53a
commit
5bb5fd9b45
@ -1,3 +1,26 @@
|
||||
import { message, danger } from 'danger';
|
||||
import { fail, danger } from 'danger';
|
||||
import { flatten, intersection, isEmpty, includes } from 'lodash';
|
||||
|
||||
message(`:tada:, this worked @${danger.github.pr.user.login}`);
|
||||
const pkg = require('./package.json'); // eslint-disable-line import/newline-after-import
|
||||
const prLogConfig = pkg['pr-log'];
|
||||
|
||||
const checkRequiredLabels = labels => {
|
||||
const requiredLabels = flatten([
|
||||
prLogConfig.skipLabels || [],
|
||||
Object.keys(prLogConfig.validLabels || {}),
|
||||
]);
|
||||
|
||||
if (includes(labels, 'do not merge')) {
|
||||
fail('PR is marked with "do not merge" label.');
|
||||
}
|
||||
|
||||
const foundLabels = intersection(requiredLabels, labels);
|
||||
if (isEmpty(foundLabels)) {
|
||||
fail(`PR is not labeled with one of: ${JSON.stringify(requiredLabels)}`);
|
||||
}
|
||||
};
|
||||
|
||||
if (prLogConfig) {
|
||||
const { labels } = danger.github.issue;
|
||||
checkRequiredLabels(labels.map(l => l.name));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user