@@ -21,8 +21,10 @@ name: productionize
21
21
22
22
# Workflow triggers:
23
23
on :
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 :
25
25
push :
26
+ branches :
27
+ - main
26
28
27
29
# Allow the workflow to be manually run:
28
30
workflow_dispatch :
@@ -309,21 +311,12 @@ jobs:
309
311
git add -A
310
312
git commit -m "Auto-generated commit"
311
313
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'
314
316
run : |
315
317
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
327
320
328
321
# Send status to Slack channel if job fails:
329
322
- name : ' Send status to Slack channel in case of failure'
@@ -482,21 +475,12 @@ jobs:
482
475
git add -A
483
476
git commit -m "Auto-generated commit"
484
477
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'
487
480
run : |
488
481
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
500
484
501
485
# Send status to Slack channel if job fails:
502
486
- name : ' Send status to Slack channel in case of failure'
@@ -661,21 +645,12 @@ jobs:
661
645
git add -A
662
646
git commit -m "Auto-generated commit"
663
647
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'
666
650
run : |
667
651
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
679
654
680
655
# Send status to Slack channel if job fails:
681
656
- name : ' Send status to Slack channel in case of failure'
@@ -685,3 +660,32 @@ jobs:
685
660
steps : ${{ toJson(steps) }}
686
661
channel : ' #npm-ci'
687
662
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