@@ -93,7 +93,31 @@ module.exports = async ({ github, context }) => {
93
93
return ;
94
94
}
95
95
96
+ // commands for GH issues
96
97
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 ) {
97
121
if ( commentBody . indexOf ( "/ok-to-e2e-test" ) == 0 ) {
98
122
// Get pull request
99
123
const pull = await github . pulls . get ( {
@@ -102,42 +126,24 @@ module.exports = async ({ github, context }) => {
102
126
pull_number : issue . number
103
127
} ) ;
104
128
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 = {
107
131
pull_head_ref : pull . data . head . sha ,
108
132
pull_head_repo : pull . data . head . repo . full_name ,
109
133
command : "ok-to-e2e-test" ,
110
134
issue : issue ,
111
- } ;
135
+ } ;
112
136
113
137
// Fire repository_dispatch event to trigger e2e test
114
138
await github . repos . createDispatchEvent ( {
115
139
owner : issue . owner ,
116
140
repo : issue . repo ,
117
141
event_type : "e2e-test" ,
118
- client_payload : testPayload ,
142
+ client_payload : clientPayload ,
119
143
} ) ;
120
144
121
- console . log ( `Trigger E2E test for ${ JSON . stringify ( testPayload ) } ` ) ;
145
+ console . log ( `Trigger E2E test for ${ JSON . stringify ( clientPayload ) } ` ) ;
122
146
}
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 ;
141
147
}
142
148
}
143
149
}
0 commit comments