Skip to content

Commit

Permalink
Chore: adds trusted bots to danger
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed May 4, 2021
1 parent 0576a01 commit 892f4a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@ const src = danger.git.fileMatch('src/*');
const tests = danger.git.fileMatch('tests/*');
const system = danger.git.fileMatch('.*', '.*/**', 'LICENSE.md', 'package-lock.json', 'package.json');
const isOwner = danger.github.pr.user.login === danger.github.thisPR.owner;
const renovateBot = 29139614;
const TrustedBots = [ renovateBot ];
// const isBot = danger.github.pr.user.type === 'Bot';
const isTrustedBot = TrustedBots.includes(danger.github.pr.user.id);
const modifiedList = danger.git.modified_files.join('\n\n- ');

export default async function () {
message(`Changed Files in this PR:\n\n- ${modifiedList}`);

const { data: contributors } = await danger.github.api.repos.listContributors(danger.github.thisPR);
const contributor = contributors.find(c => c.login === danger.github.pr.user.login);

if (contributor) {
message(`${contributor} login already contributed ${contributor.contributions} times`);
}

if (system.modified && !isOwner) {
const files = system.getKeyedPaths().modified;
const level = (contributor || isTrustedBot) ? warn : fail;

fail(`Only owner can change system files [${files.join(', ')}], please provide issue instead`, files[0]);
level(`Only owner can change system files [${files.join(', ')}], please provide issue instead`, files[0]);
}

if (src.modified && !tests.modified) {
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.dangerfile.js

0 comments on commit 892f4a1

Please sign in to comment.