@@ -42,6 +42,8 @@ const { labels } = danger.github.issue;
4242const prLogConfig = pkg [ 'pr-log' ] ;
4343
4444const branchVersion = Versions . MINOR ;
45+ const targetBranch = danger . github . pr . base . ref ;
46+ const isReleasePr = [ 'latest-release' , 'next-release' ] . includes ( targetBranch ) ;
4547
4648/** @param {string[] } labels */
4749const checkRequiredLabels = ( labels ) => {
@@ -66,18 +68,29 @@ const checkRequiredLabels = (labels) => {
6668 ) ;
6769 }
6870
69- const foundRequiredLabels = intersection ( requiredLabels , labels ) ;
70- if ( foundRequiredLabels . length === 0 ) {
71- fail ( `PR is not labeled with one of: ${ JSON . stringify ( requiredLabels ) } ` ) ;
72- } else if ( foundRequiredLabels . length > 1 ) {
73- fail ( `Please choose only one of these labels: ${ JSON . stringify ( foundRequiredLabels ) } ` ) ;
74- }
75-
76- const foundCILabels = intersection ( ciLabels , labels ) ;
77- if ( foundCILabels . length === 0 ) {
78- fail ( `PR is not labeled with one of: ${ JSON . stringify ( ciLabels ) } ` ) ;
79- } else if ( foundCILabels . length > 1 ) {
80- fail ( `Please choose only one of these labels: ${ JSON . stringify ( foundCILabels ) } ` ) ;
71+ if ( isReleasePr ) {
72+ // Release PRs only need `ci:daily`.
73+ if ( ! labels . includes ( 'ci:daily' ) ) {
74+ fail (
75+ 'Release PRs targeting latest-release or next-release must include the "ci:daily" label.'
76+ ) ;
77+ }
78+ return ;
79+ } else {
80+ // All other PRs to `next` to a qualifying change type and one of several applicable CI labels.
81+ const foundRequiredLabels = intersection ( requiredLabels , labels ) ;
82+ if ( foundRequiredLabels . length === 0 ) {
83+ fail ( `PR is not labeled with one of: ${ JSON . stringify ( requiredLabels ) } ` ) ;
84+ } else if ( foundRequiredLabels . length > 1 ) {
85+ fail ( `Please choose only one of these labels: ${ JSON . stringify ( foundRequiredLabels ) } ` ) ;
86+ }
87+
88+ const foundCILabels = intersection ( ciLabels , labels ) ;
89+ if ( foundCILabels . length === 0 ) {
90+ fail ( `PR is not labeled with one of: ${ JSON . stringify ( ciLabels ) } ` ) ;
91+ } else if ( foundCILabels . length > 1 ) {
92+ fail ( `Please choose only one of these labels: ${ JSON . stringify ( foundCILabels ) } ` ) ;
93+ }
8194 }
8295} ;
8396
0 commit comments