1- const { hasIntermediateEligibility } = require ( '../lib/eligibility/has-eligibility-03-intermediate' ) ;
2- const { rejectionRouter } = require ( '../lib/comments/rejection-router' ) ;
1+ const { hasIntermediateEligibility } =
2+ require ( '../lib/eligibility/has-eligibility-03-intermediate' ) ;
3+ const { rejectionRouter } =
4+ require ( '../lib/comments/rejection-router' ) ;
35
46const INTERMEDIATE_LABEL = 'Intermediate' ;
57
68function isIntermediate ( issue ) {
7- return ( issue . labels ?? [ ] ) . some ( l => l . name === INTERMEDIATE_LABEL ) ;
9+ return ( issue . labels ?? [ ] ) . some (
10+ l => l . name ?. toLowerCase ( ) === INTERMEDIATE_LABEL . toLowerCase ( )
11+ ) ;
812}
913
1014module . exports = async ( { github, context } ) => {
15+ console . log ( '[intermediate-enforce] Workflow triggered' , {
16+ action : context . payload . action ,
17+ issue : context . payload . issue ?. number ,
18+ assignee : context . payload . assignee ?. login ,
19+ labels : context . payload . issue ?. labels ?. map ( l => l . name ) ,
20+ } ) ;
21+
1122 const { issue, assignee } = context . payload ;
1223 const { owner, repo } = context . repo ;
1324
14- if ( ! issue || ! assignee ) return ;
15- if ( ! isIntermediate ( issue ) ) return ;
25+ if ( ! issue || ! assignee ) {
26+ console . log ( '[intermediate-enforce] Exit: missing issue or assignee' ) ;
27+ return ;
28+ }
29+
30+ if ( ! isIntermediate ( issue ) ) {
31+ console . log ( '[intermediate-enforce] Exit: issue is not Intermediate' ) ;
32+ return ;
33+ }
1634
1735 const username = assignee . login ;
1836
37+ console . log ( '[intermediate-enforce] Checking eligibility' , {
38+ issue : issue . number ,
39+ username,
40+ } ) ;
41+
1942 const result = await hasIntermediateEligibility ( {
2043 github,
2144 owner,
2245 repo,
2346 username,
2447 } ) ;
2548
49+ console . log ( '[intermediate-enforce] Eligibility result' , {
50+ issue : issue . number ,
51+ username,
52+ eligible : result . eligible ,
53+ reason : result . reason ,
54+ context : result . context ,
55+ } ) ;
56+
2657 if ( result . eligible ) {
2758 console . log ( '[intermediate-enforce] Assignment allowed' , {
2859 issue : issue . number ,
@@ -32,6 +63,11 @@ module.exports = async ({ github, context }) => {
3263 }
3364
3465 // ❌ Not eligible → unassign
66+ console . log ( '[intermediate-enforce] Reverting assignment' , {
67+ issue : issue . number ,
68+ username,
69+ } ) ;
70+
3571 await github . rest . issues . removeAssignees ( {
3672 owner,
3773 repo,
@@ -46,12 +82,22 @@ module.exports = async ({ github, context }) => {
4682 } ) ;
4783
4884 if ( body ) {
85+ console . log ( '[intermediate-enforce] Posting rejection comment' , {
86+ issue : issue . number ,
87+ username,
88+ reason : result . reason ,
89+ } ) ;
90+
4991 await github . rest . issues . createComment ( {
5092 owner,
5193 repo,
5294 issue_number : issue . number ,
5395 body,
5496 } ) ;
97+ } else {
98+ console . log ( '[intermediate-enforce] No rejection message generated' , {
99+ reason : result . reason ,
100+ } ) ;
55101 }
56102
57103 console . log ( '[intermediate-enforce] Assignment reverted' , {
0 commit comments