3030
3131 steps :
3232 - name : Get repository from pull request comment
33- uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 .0.1
33+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 .0.0
3434 id : get-repository
3535 with :
3636 github-token : ${{secrets.GITHUB_TOKEN}}
5757 require : write
5858
5959 - name : Add reaction on start
60- uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 .0.0
60+ uses : peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 .0.0
6161 with :
6262 token : ${{ secrets.COMMAND_BOT_PAT }}
6363 repository : ${{ github.event.repository.full_name }}
8383 id : comment-branch
8484
8585 - name : Add reaction on failure
86- uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 .0.0
86+ uses : peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 .0.0
8787 if : failure()
8888 with :
8989 token : ${{ secrets.COMMAND_BOT_PAT }}
@@ -103,7 +103,7 @@ jobs:
103103 key : git-repo
104104
105105 - name : Checkout ${{ needs.init.outputs.head_ref }}
106- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
106+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
107107 with :
108108 # Needed to allow force push later
109109 persist-credentials : true
@@ -124,19 +124,53 @@ jobs:
124124 fallbackNpm : ' ^10'
125125
126126 - name : Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
127- uses : actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1 .0
127+ uses : actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0 .0
128128 with :
129129 node-version : ${{ steps.package-engines-versions.outputs.nodeVersion }}
130130 cache : npm
131131
132132 - name : Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
133133 run : npm i -g 'npm@${{ steps.package-engines-versions.outputs.npmVersion }}'
134-
134+
135135 - name : Rebase to ${{ needs.init.outputs.base_ref }}
136136 if : ${{ contains(needs.init.outputs.arg1, 'rebase') }}
137137 run : |
138138 git fetch origin '${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}'
139- git rebase 'origin/${{ needs.init.outputs.base_ref }}'
139+
140+ # Start the rebase
141+ git rebase 'origin/${{ needs.init.outputs.base_ref }}' || {
142+ # Handle rebase conflicts in a loop
143+ while [ -d .git/rebase-merge ] || [ -d .git/rebase-apply ]; do
144+ echo "Handling rebase conflict..."
145+
146+ # Remove and checkout /dist and /js folders from the base branch
147+ if [ -d "dist" ]; then
148+ rm -rf dist
149+ git checkout origin/${{ needs.init.outputs.base_ref }} -- dist/ 2>/dev/null || echo "No dist folder in base branch"
150+ fi
151+ if [ -d "js" ]; then
152+ rm -rf js
153+ git checkout origin/${{ needs.init.outputs.base_ref }} -- js/ 2>/dev/null || echo "No js folder in base branch"
154+ fi
155+
156+ # Stage all changes
157+ git add .
158+
159+ # Check if there are any changes after resolving conflicts
160+ if git diff --cached --quiet; then
161+ echo "No changes after conflict resolution, skipping commit"
162+ git rebase --skip
163+ else
164+ echo "Changes found, continuing rebase without editing commit message"
165+ git -c core.editor=true rebase --continue
166+ fi
167+
168+ # Break if rebase is complete
169+ if [ ! -d .git/rebase-merge ] && [ ! -d .git/rebase-apply ]; then
170+ break
171+ fi
172+ done
173+ }
140174
141175 - name : Install dependencies & build
142176 env :
@@ -151,7 +185,7 @@ jobs:
151185 run : |
152186 git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
153187 git commit --signoff -m 'chore(assets): Recompile assets'
154-
188+
155189 - name : Commit fixup
156190 if : ${{ contains(needs.init.outputs.arg1, 'fixup') }}
157191 run : |
@@ -168,14 +202,18 @@ jobs:
168202
169203 - name : Push normally
170204 if : ${{ !contains(needs.init.outputs.arg1, 'rebase') && !contains(needs.init.outputs.arg1, 'amend') }}
171- run : git push origin '${{ needs.init.outputs.head_ref }}'
205+ env :
206+ HEAD_REF : ${{ needs.init.outputs.head_ref }}
207+ run : git push origin "$HEAD_REF"
172208
173209 - name : Force push
174210 if : ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
175- run : git push --force origin '${{ needs.init.outputs.head_ref }}'
211+ env :
212+ HEAD_REF : ${{ needs.init.outputs.head_ref }}
213+ run : git push --force-with-lease origin "$HEAD_REF"
176214
177215 - name : Add reaction on failure
178- uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 .0.0
216+ uses : peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 .0.0
179217 if : failure()
180218 with :
181219 token : ${{ secrets.COMMAND_BOT_PAT }}
0 commit comments