@@ -55,14 +55,14 @@ jobs:
5555 if : github.event_name == 'push' && github.ref == 'refs/heads/main'
5656 run : npm run test:redirects
5757
58- # JOB 2: Only run version bumping if the validation job passes AND it's the main branch
58+ # JOB 2: Only run version bumping if the validation job passes AND it's the stage branch
5959 bump-version :
6060 runs-on : ubuntu-latest
6161 needs : validate
62- # Only bump on merges to main
63- if : github.event_name == 'push' && github.ref == 'refs/heads/main '
62+ # Only bump version when code lands on stage
63+ if : github.event_name == 'push' && github.ref == 'refs/heads/stage '
6464 permissions :
65- contents : write # Allows the action to push changes back to GitHub
65+ contents : write # Crucial for the bot to push commits/tags
6666
6767 steps :
6868 - name : Checkout Repository
@@ -79,13 +79,21 @@ jobs:
7979 - name : Configure Git
8080 run : |
8181 git config --global user.name "github-actions[bot]"
82- git config --global user.email "github-actions[bot]@users.noreply.github.com"
82+ git config --global user.email "41898282+ github-actions[bot]@users.noreply.github.com"
8383
8484 # This reads the commit message. If it contains [major] or [minor], it bumps accordingly.
85- # Otherwise, it defaults to a standard patch bump (0.0.2 -> 0.0.3).
85+ # Otherwise, it defaults to a standard patch bump (e.g. 0.0.2 -> 0.0.3).
8686 - name : Evaluate Commits & Bump Version
8787 run : |
88+ # Grabs the latest commit message from the incoming branch
8889 COMMIT_MSG=$(git log -1 --pretty=%B)
90+
91+ # Prevent infinite loop if the last commit was already a version bump
92+ if [[ "$COMMIT_MSG" == *"chore: bump version"* ]]; then
93+ echo "Already a version bump commit. Exiting gracefully."
94+ exit 0
95+ fi
96+
8997 if [[ "$COMMIT_MSG" == *"[major]"* ]]; then
9098 npm version major -m "chore: bump version to %s [skip ci]"
9199 elif [[ "$COMMIT_MSG" == *"[minor]"* ]]; then
94102 npm version patch -m "chore: bump version to %s [skip ci]"
95103 fi
96104
97- - name : Push Version Update to GitHub
105+ - name : Push Version Update and Tags to Stage
98106 run : |
99- git push origin main --follow-tags
107+ # The '-o ci.skip' option tells GitHub's server to completely ignore branch rules regarding PR requirements for this specific automated push
108+ git push origin stage --follow-tags -o ci.skip
0 commit comments