@@ -211,31 +211,32 @@ async function handlePushEvent(branch, jiraUtil, githubRepository, githubToken)
211
211
212
212
const preparedFields = await prepareFields ( customFields , jiraUtil )
213
213
214
- // Handle special case: staging -> production bulk update
214
+ const prMatch = commitMessage . match ( / # ( [ 0 - 9 ] + ) / )
215
215
if ( ( branch === 'master' || branch === 'main' ) ) {
216
+ // Handle special case: staging -> production bulk update
216
217
if ( commitMessage === 'from coursedog/staging' ) {
218
+ console . log ( 'Bulk updating all Staging issues to Done' )
219
+ const issues = await jiraUtil . updateByStatus ( 'Deployed to Staging' , newStatus , preparedFields )
220
+ console . log ( `Issues deployed to production: ${ issues . length } ` )
221
+ return
222
+ }
217
223
218
- } else if ( commitMessage . match ( / # + [ 0 - 9 ] / ) ) {
219
- // direct from open PR to staging
224
+ // direct from open PR to staging
225
+ if ( prMatch ) {
220
226
const prNumber = extractPrNumber ( commitMessage )
221
227
const prUrl = `${ repositoryName } /pull/${ prNumber } `
222
228
if ( ! prNumber ) return
223
- jiraUtil . updateByPR ( prUrl , newStatus , preparedFields )
229
+ await jiraUtil . updateByPR ( prUrl , newStatus , preparedFields )
230
+ return
224
231
}
225
-
226
- console . log ( 'Bulk updating all Staging issues to Done' )
227
- const issues = await jiraUtil . updateByStatus ( 'Deployed to Staging' , newStatus , preparedFields )
228
-
229
- return
230
232
}
231
233
232
234
if ( branch === 'staging' ) {
233
235
console . log ( 'Bulk updating all Deployed to Dev issues to Deployed to Staging' )
234
- const issues = await jiraUtil . updateByStatus ( 'Deployed to Dev ' , newStatus , preparedFields )
236
+ await jiraUtil . updateByStatus ( 'Deployed to Staging ' , newStatus , preparedFields )
235
237
}
236
238
237
239
// Handle PR merges (look for PR number in commit message)
238
- const prMatch = commitMessage . match ( / # ( [ 0 - 9 ] + ) / )
239
240
if ( prMatch ) {
240
241
const prNumber = prMatch [ 1 ]
241
242
const prUrl = `${ repositoryName } /pull/${ prNumber } `
0 commit comments