@@ -93,7 +93,31 @@ module.exports = async ({ github, context }) => {
9393 return ;
9494 }
9595
96+ // commands for GH issues
9697 if ( ! isFromPulls && commentBody ) {
98+ if ( commentBody . indexOf ( "/ping-author" ) == 0 ) {
99+ // if there is a 'needs-team-attention' label, remove it.
100+ await executeIfIssueHasLabel ( github , issue , 'needs-team-attention' , async ( ) => {
101+ await github . issues . removeLabel ( {
102+ issue_number : issue . number ,
103+ owner : issue . owner ,
104+ repo : issue . repo ,
105+ name : 'needs-team-attention'
106+ } ) ;
107+ } )
108+ // Add new label
109+ await github . issues . addLabels ( {
110+ issue_number : issue . number ,
111+ owner : issue . owner ,
112+ repo : issue . repo ,
113+ labels : [ 'needs-author-feedback' ]
114+ } )
115+ return ;
116+ }
117+ }
118+
119+ // commands for GH pull requests
120+ if ( isFromPulls && commentBody ) {
97121 if ( commentBody . indexOf ( "/ok-to-e2e-test" ) == 0 ) {
98122 // Get pull request
99123 const pull = await github . pulls . get ( {
@@ -102,42 +126,24 @@ module.exports = async ({ github, context }) => {
102126 pull_number : issue . number
103127 } ) ;
104128 if ( pull && pull . data ) {
105- // Get commit id and repo from pull head
106- const testPayload = {
129+ // Get commit id and repo from pull head
130+ const clientPayload = {
107131 pull_head_ref : pull . data . head . sha ,
108132 pull_head_repo : pull . data . head . repo . full_name ,
109133 command : "ok-to-e2e-test" ,
110134 issue : issue ,
111- } ;
135+ } ;
112136
113137 // Fire repository_dispatch event to trigger e2e test
114138 await github . repos . createDispatchEvent ( {
115139 owner : issue . owner ,
116140 repo : issue . repo ,
117141 event_type : "e2e-test" ,
118- client_payload : testPayload ,
142+ client_payload : clientPayload ,
119143 } ) ;
120144
121- console . log ( `Trigger E2E test for ${ JSON . stringify ( testPayload ) } ` ) ;
145+ console . log ( `Trigger E2E test for ${ JSON . stringify ( clientPayload ) } ` ) ;
122146 }
123- } else if ( commentBody . indexOf ( "/ping-author" ) == 0 ) {
124- // if there is a 'needs-team-attention' label, remove it.
125- await executeIfIssueHasLabel ( github , issue , 'needs-team-attention' , async ( ) => {
126- await github . issues . removeLabel ( {
127- issue_number : issue . number ,
128- owner : issue . owner ,
129- repo : issue . repo ,
130- name : 'needs-team-attention'
131- } ) ;
132- } )
133- // Add new label
134- await github . issues . addLabels ( {
135- issue_number : issue . number ,
136- owner : issue . owner ,
137- repo : issue . repo ,
138- labels : [ 'needs-author-feedback' ]
139- } )
140- return ;
141147 }
142148 }
143149}
0 commit comments