@@ -21,8 +21,10 @@ name: productionize
2121
2222#  Workflow triggers:
2323on :
24-   #  Run workflow when a new commit is pushed to the repository :
24+   #  Run workflow when a new commit is pushed to the main branch :
2525  push :
26+     branches :
27+       - main 
2628
2729  #  Allow the workflow to be manually run:
2830  workflow_dispatch :
@@ -309,21 +311,12 @@ jobs:
309311          git add -A 
310312          git commit -m "Auto-generated commit" 
311313
312-        #  Push changes to `deno` branch or create new branch tag :
313-       - name : ' Push changes to `deno` branch or create new branch tag ' 
314+        #  Push changes to `deno` branch:
315+       - name : ' Push changes to `deno` branch' 
314316        run : | 
315317          SLUG=${{ github.repository }} 
316-           VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') 
317-           if [ -z "$VERSION" ]; then 
318-             echo "Workflow job was not triggered by a new tag...." 
319-             echo "Pushing changes to $SLUG..." 
320-             git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno 
321-           else 
322-             echo "Workflow job was triggered by a new tag: $VERSION" 
323-             echo "Creating new bundle branch tag of the form $VERSION-deno" 
324-             git tag -a $VERSION-deno -m "$VERSION-deno" 
325-             git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno 
326-           fi 
318+           echo "Pushing changes to $SLUG..." 
319+           git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno 
327320
328321       #  Send status to Slack channel if job fails:
329322      - name : ' Send status to Slack channel in case of failure' 
@@ -482,21 +475,12 @@ jobs:
482475          git add -A 
483476          git commit -m "Auto-generated commit" 
484477
485-        #  Push changes to `umd` branch or create new branch tag :
486-       - name : ' Push changes to `umd` branch or create new branch tag ' 
478+        #  Push changes to `umd` branch:
479+       - name : ' Push changes to `umd` branch' 
487480        run : | 
488481          SLUG=${{ github.repository }} 
489-           VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') 
490-           if [ -z "$VERSION" ]; then 
491-             echo "Workflow job was not triggered by a new tag...." 
492-             echo "Pushing changes to $SLUG..." 
493-             git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd 
494-           else 
495-             echo "Workflow job was triggered by a new tag: $VERSION" 
496-             echo "Creating new bundle branch tag of the form $VERSION-umd" 
497-             git tag -a $VERSION-umd -m "$VERSION-umd" 
498-             git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-umd 
499-           fi 
482+           echo "Pushing changes to $SLUG..." 
483+           git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd 
500484
501485       #  Send status to Slack channel if job fails:
502486      - name : ' Send status to Slack channel in case of failure' 
@@ -661,21 +645,12 @@ jobs:
661645          git add -A 
662646          git commit -m "Auto-generated commit" 
663647
664-        #  Push changes to `esm` branch or create new branch tag :
665-       - name : ' Push changes to `esm` branch or create new branch tag ' 
648+        #  Push changes to `esm` branch:
649+       - name : ' Push changes to `esm` branch' 
666650        run : | 
667651          SLUG=${{ github.repository }} 
668-           VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') 
669-           if [ -z "$VERSION" ]; then 
670-             echo "Workflow job was not triggered by a new tag...." 
671-             echo "Pushing changes to $SLUG..." 
672-             git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm 
673-           else 
674-             echo "Workflow job was triggered by a new tag: $VERSION" 
675-             echo "Creating new bundle branch tag of the form $VERSION-esm" 
676-             git tag -a $VERSION-esm -m "$VERSION-esm" 
677-             git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-esm 
678-           fi 
652+           echo "Pushing changes to $SLUG..." 
653+           git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm 
679654
680655       #  Send status to Slack channel if job fails:
681656      - name : ' Send status to Slack channel in case of failure' 
@@ -685,3 +660,32 @@ jobs:
685660          steps : ${{ toJson(steps) }} 
686661          channel : ' #npm-ci' 
687662        if : failure() 
663+ 
664+   #  Define job that succeeds if all bundles were successfully built:
665+   productionize-status :
666+ 
667+     #  Define display name:
668+     name : ' Productionize status' 
669+ 
670+     #  Define the type of virtual host machine on which to run the job:
671+     runs-on : ubuntu-latest 
672+ 
673+     #  Indicate that this job depends on the prior jobs finishing:
674+     needs : [ deno, umd, esm ] 
675+ 
676+     #  Define the steps to be executed:
677+     steps :
678+ 
679+       - name : ' If all bundles were successfully generated...' 
680+         if : always() && (needs.deno.result == 'success' && needs.umd.result == 'success' && needs.esm.result == 'success') 
681+         run : | 
682+           echo "All bundles were successfully built." 
683+           echo "Success!" 
684+           exit 0 
685+ 
686+        - name : ' If any bundle failed to be generated...' 
687+         if : always() && (needs.deno.result == 'failure' || needs.umd.result == 'failure' || needs.esm.result == 'failure') 
688+         run : | 
689+           echo "One or more bundles failed to be generated." 
690+           echo "Failure!" 
691+           exit 1 
0 commit comments