Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/danger-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ on:
- unlabeled
- edited
branches:
- main
- next
- "**"

concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
Expand Down
24 changes: 23 additions & 1 deletion scripts/dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Why: We want Danger to run as fast as possible in CI without installing dependencies or running
* build processes.
*/
import { danger, fail } from 'danger';
import { danger, fail, warn } from 'danger';

/**
* Returns the intersection of two arrays
Expand Down Expand Up @@ -145,6 +145,28 @@ const checkManualTestingSection = (body) => {
}
};

const checkTargetBranch = () => {
const targetBranch = danger.github.pr.base.ref;
const authorAssociation = danger.github.pr.author_association;

// Only check for non-team members (not OWNER or MEMBER)
if (['OWNER', 'MEMBER'].includes(authorAssociation)) {
return;
}

if (targetBranch === 'main' || targetBranch.includes('release')) {
fail(
`This PR targets \`${targetBranch}\`, but it should target \`next\`. Please update the base branch of your PR.`
);
} else if (targetBranch !== 'next') {
warn(
`This PR targets \`${targetBranch}\`. The default branch for contributions is \`next\`. Please make sure you are targeting the correct branch.`
);
}
};

checkTargetBranch();

if (prLogConfig) {
checkRequiredLabels(labels.map((l) => l.name));
checkPrTitle(danger.github.pr.title);
Expand Down
Loading