Skip to content

Commit b69ab38

Browse files
lantoliCopilot
andauthored
chore: Use rebase instead of merge to update dev branches (#3442)
* use rebase instead of merge to update dev branches * Update .github/workflows/update-dev-branches.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * improve doc --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent f4b73cb commit b69ab38

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

.github/workflows/update-dev-branches.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
branches:
77
description: 'Dev branch names to update from master'
88
default: '["CLOUDP-320243-dev-2.0.0"]'
9+
force-auto-resolve:
10+
description: 'Force auto-resolve conflicts by favoring master changes. Some changes in dev branch might be lost.'
11+
required: false
12+
default: false
13+
type: boolean
914
schedule:
1015
- cron: "0 5 * * 3" # workflow runs every Wednesday at 5 AM UTC
1116

@@ -45,16 +50,24 @@ jobs:
4550
git fetch origin ${{ matrix.branch }}
4651
git checkout -B ${{ matrix.branch }} origin/${{ matrix.branch }}
4752
48-
if git merge origin/master --no-edit; then
49-
echo "OK: Merge completed successfully with no conflicts."
53+
if git rebase origin/master; then
54+
echo "OK: Rebase completed successfully with no conflicts."
5055
else
51-
git merge --abort
52-
if git merge origin/master --strategy-option=theirs --no-edit; then
53-
echo "ERROR: Merge conflicts detected that can be auto-resolved by favoring master changes."
56+
# Check if conflicts can be auto-resolved
57+
git rebase --abort
58+
if git rebase origin/master -X theirs; then
59+
if [ "${{ inputs.force-auto-resolve }}" = "true" ]; then
60+
echo "WARNING: Rebase conflicts detected but auto-resolved by favoring master changes because force-auto-resolve is true."
61+
else
62+
echo "ERROR: Rebase conflicts detected that can be auto-resolved by favoring master changes."
63+
echo "Manual review required to ensure no important changes are lost. Set force-auto-resolve to true to auto-resolve these conflicts."
64+
git rebase --abort
65+
exit 1
66+
fi
5467
else
55-
echo "ERROR: Merge conflicts detected that need manual intervention."
68+
echo "ERROR: Rebase conflicts detected that need manual intervention, they can't be auto-resolved."
69+
exit 1
5670
fi
57-
exit 1
5871
fi
5972
6073
- uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e

0 commit comments

Comments
 (0)