@@ -105,8 +105,7 @@ jobs:
105105 - name : Checkout ${{ needs.init.outputs.head_ref }}
106106 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
107107 with :
108- # Needed to allow force push later
109- persist-credentials : true
108+ persist-credentials : false
110109 token : ${{ secrets.COMMAND_BOT_PAT }}
111110 fetch-depth : 0
112111 ref : ${{ needs.init.outputs.head_ref }}
@@ -134,23 +133,25 @@ jobs:
134133
135134 - name : Rebase to ${{ needs.init.outputs.base_ref }}
136135 if : ${{ contains(needs.init.outputs.arg1, 'rebase') }}
136+ env :
137+ BASE_REF : ${{ needs.init.outputs.base_ref }}
137138 run : |
138- git fetch origin '${{ needs.init.outputs.base_ref }} :${{ needs.init.outputs.base_ref }}'
139+ git fetch origin "${BASE_REF} :${BASE_REF}"
139140
140141 # Start the rebase
141- git rebase ' origin/${{ needs.init.outputs.base_ref }}' || {
142+ git rebase " origin/${BASE_REF}" || {
142143 # Handle rebase conflicts in a loop
143144 while [ -d .git/rebase-merge ] || [ -d .git/rebase-apply ]; do
144145 echo "Handling rebase conflict..."
145146
146147 # Remove and checkout /dist and /js folders from the base branch
147148 if [ -d "dist" ]; then
148149 rm -rf dist
149- git checkout origin/${{ needs.init.outputs.base_ref }} -- dist/ 2>/dev/null || echo "No dist folder in base branch"
150+ git checkout " origin/${BASE_REF}" -- dist/ 2>/dev/null || echo "No dist folder in base branch"
150151 fi
151152 if [ -d "js" ]; then
152153 rm -rf js
153- git checkout origin/${{ needs.init.outputs.base_ref }} -- js/ 2>/dev/null || echo "No js folder in base branch"
154+ git checkout " origin/${BASE_REF}" -- js/ 2>/dev/null || echo "No js folder in base branch"
154155 fi
155156
156157 # Stage all changes
@@ -182,20 +183,26 @@ jobs:
182183
183184 - name : Commit default
184185 if : ${{ !contains(needs.init.outputs.arg1, 'fixup') && !contains(needs.init.outputs.arg1, 'amend') }}
186+ env :
187+ GIT_PATH : ${{ needs.init.outputs.git_path }}
185188 run : |
186- git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
189+ git add "${GITHUB_WORKSPACE}${GIT_PATH}"
187190 git commit --signoff -m 'chore(assets): Recompile assets'
188191
189192 - name : Commit fixup
190193 if : ${{ contains(needs.init.outputs.arg1, 'fixup') }}
194+ env :
195+ GIT_PATH : ${{ needs.init.outputs.git_path }}
191196 run : |
192- git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
197+ git add "${GITHUB_WORKSPACE}${GIT_PATH}"
193198 git commit --fixup=HEAD --signoff
194199
195200 - name : Commit amend
196201 if : ${{ contains(needs.init.outputs.arg1, 'amend') }}
202+ env :
203+ GIT_PATH : ${{ needs.init.outputs.git_path }}
197204 run : |
198- git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
205+ git add "${GITHUB_WORKSPACE}${GIT_PATH}"
199206 git commit --amend --no-edit --signoff
200207 # Remove any [skip ci] from the amended commit
201208 git commit --amend -m "$(git log -1 --format='%B' | sed '/\[skip ci\]/d')"
@@ -204,13 +211,19 @@ jobs:
204211 if : ${{ !contains(needs.init.outputs.arg1, 'rebase') && !contains(needs.init.outputs.arg1, 'amend') }}
205212 env :
206213 HEAD_REF : ${{ needs.init.outputs.head_ref }}
207- run : git push origin "$HEAD_REF"
214+ BOT_TOKEN : ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env]
215+ run : |
216+ git remote set-url origin "https://x-access-token:${BOT_TOKEN}@github.com/${{ github.repository }}.git"
217+ git push origin "$HEAD_REF"
208218
209219 - name : Force push
210220 if : ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
211221 env :
212222 HEAD_REF : ${{ needs.init.outputs.head_ref }}
213- run : git push --force-with-lease origin "$HEAD_REF"
223+ BOT_TOKEN : ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env]
224+ run : |
225+ git remote set-url origin "https://x-access-token:${BOT_TOKEN}@github.com/${{ github.repository }}.git"
226+ git push --force-with-lease origin "$HEAD_REF"
214227
215228 - name : Add reaction on failure
216229 uses : peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
0 commit comments