|
6 | 6 | branches:
|
7 | 7 | description: 'Dev branch names to update from master'
|
8 | 8 | 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 |
9 | 14 | schedule:
|
10 | 15 | - cron: "0 5 * * 3" # workflow runs every Wednesday at 5 AM UTC
|
11 | 16 |
|
@@ -45,16 +50,24 @@ jobs:
|
45 | 50 | git fetch origin ${{ matrix.branch }}
|
46 | 51 | git checkout -B ${{ matrix.branch }} origin/${{ matrix.branch }}
|
47 | 52 |
|
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." |
50 | 55 | 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 |
54 | 67 | 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 |
56 | 70 | fi
|
57 |
| - exit 1 |
58 | 71 | fi
|
59 | 72 |
|
60 | 73 | - uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
|
|
0 commit comments