1818      - name : Checkout 
1919        uses : actions/checkout@v4 
2020        with :
21+           fetch-depth : 0 
2122          ref : ${{ github.event.pull_request.head.ref || github.event.ref }} 
2223
2324      - name : Remove label 
@@ -29,14 +30,24 @@ jobs:
2930          gh pr edit --repo github/codeql-action "$PR_NUMBER" \ 
3031            --remove-label "Rebuild" 
3132
33+ name : Configure git 
34+         run : | 
35+           git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" 
36+           git config --global user.name "github-actions[bot]" 
37+ 
3238name : Merge in changes from base branch 
39+         id : merge 
3340        env :
3441          BASE_BRANCH : ${{ github.event.pull_request.base.ref || 'main' }} 
3542        run : | 
3643          git fetch origin "$BASE_BRANCH" 
3744
3845          # Allow merge conflicts in `lib`, since rebuilding should resolve them. 
39-           git merge "origin/$BASE_BRANCH" || echo "Merge conflicts detected, continuing..." 
46+           git merge "origin/$BASE_BRANCH" || MERGE_RESULT=$? 
47+ 
48+           if [ -n "$MERGE_RESULT" ]; then 
49+             echo "merge-in-progress=true" >> $GITHUB_OUTPUT 
50+           fi 
4051
4152          # Check for merge conflicts outside of `lib`. Disable git diff's trailing whitespace check 
4253          # since `node_modules/@types/semver/README.md` fails it. 
@@ -67,13 +78,20 @@ jobs:
6778          pip install ruamel.yaml==0.17.31 
6879          python3 sync.py 
6980
70- name : Check for changes and push 
81+ name : " Merge in progress: Finish merge and push" 
82+         if : steps.merge.outputs.merge-in-progress == 'true' 
83+         run : | 
84+           echo "Finishing merge and pushing changes." 
85+           git add --all 
86+           git commit --no-edit 
87+           git push 
88+ 
89+ name : " No merge in progress: Check for changes and push" 
90+         if : steps.merge.outputs.merge-in-progress != 'true' 
7191        id : push 
7292        run : | 
7393          if [ ! -z "$(git status --porcelain)" ]; then 
7494            echo "Changes detected, committing and pushing." 
75-             git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" 
76-             git config --global user.name "github-actions[bot]" 
7795            git add --all 
7896            # If the merge originally had conflicts, finish the merge. 
7997            # Otherwise, just commit the changes. 
@@ -92,7 +110,12 @@ jobs:
92110          fi 
93111
94112name : Notify about rebuild 
95-         if : github.event_name == 'pull_request' && steps.push.outputs.changes == 'true' 
113+         if : >- 
114+           github.event_name == 'pull_request' && 
115+             ( 
116+               steps.merge.outputs.merge-in-progress == 'true' || 
117+               steps.push.outputs.changes == 'true' 
118+             ) 
96119env :
97120          GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
98121          PR_NUMBER : ${{ github.event.pull_request.number }} 
0 commit comments