@@ -211,31 +211,32 @@ async function handlePushEvent(branch, jiraUtil, githubRepository, githubToken)
211211
212212 const preparedFields = await prepareFields ( customFields , jiraUtil )
213213
214- // Handle special case: staging -> production bulk update
214+ const prMatch = commitMessage . match ( / # ( [ 0 - 9 ] + ) / )
215215 if ( ( branch === 'master' || branch === 'main' ) ) {
216+ // Handle special case: staging -> production bulk update
216217 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+ }
217223
218- } else if ( commitMessage . match ( / # + [ 0 - 9 ] / ) ) {
219- // direct from open PR to staging
224+ // direct from open PR to staging
225+ if ( prMatch ) {
220226 const prNumber = extractPrNumber ( commitMessage )
221227 const prUrl = `${ repositoryName } /pull/${ prNumber } `
222228 if ( ! prNumber ) return
223- jiraUtil . updateByPR ( prUrl , newStatus , preparedFields )
229+ await jiraUtil . updateByPR ( prUrl , newStatus , preparedFields )
230+ return
224231 }
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
230232 }
231233
232234 if ( branch === 'staging' ) {
233235 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 )
235237 }
236238
237239 // Handle PR merges (look for PR number in commit message)
238- const prMatch = commitMessage . match ( / # ( [ 0 - 9 ] + ) / )
239240 if ( prMatch ) {
240241 const prNumber = prMatch [ 1 ]
241242 const prUrl = `${ repositoryName } /pull/${ prNumber } `
0 commit comments