Skip to content

Commit 36b510a

Browse files
committed
feat(workflows): drop dist and js changes when compile-rebasing
Signed-off-by: skjnldsv <[email protected]>
1 parent b8ad6d0 commit 36b510a

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

.github/workflows/command-compile.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,41 @@ jobs:
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"
165+
git 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:
@@ -172,7 +206,7 @@ jobs:
172206

173207
- name: Force push
174208
if: ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
175-
run: git push --force origin '${{ needs.init.outputs.head_ref }}'
209+
run: git push --force-with-lease origin '${{ needs.init.outputs.head_ref }}'
176210

177211
- name: Add reaction on failure
178212
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0

0 commit comments

Comments
 (0)