Skip to content

Commit 81538bc

Browse files
committed
added new 6
1 parent 5423c02 commit 81538bc

File tree

1 file changed

+65
-6
lines changed

1 file changed

+65
-6
lines changed

.github/workflows/sync-demo-branch.yml

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
sync-demo-branch:
1010
runs-on: ubuntu-latest
1111
steps:
12-
# Keep v4 for this test
12+
# Use v4, as v3 didn't help either
1313
- name: Checkout demo branch
1414
uses: actions/checkout@v4
1515
with:
@@ -23,6 +23,10 @@ jobs:
2323
echo "Checking .gitattributes content:"
2424
cat .gitattributes || echo ".gitattributes not found!"
2525
26+
# *** ADDED: Check Git Version ***
27+
- name: Check Git Version
28+
run: git --version
29+
2630
# Configure Git user for the commit
2731
- name: Configure Git User
2832
run: |
@@ -37,13 +41,68 @@ jobs:
3741
- name: Fetch origin
3842
run: git fetch origin
3943

40-
# *** CHANGE HERE: Use -X ours strategy ***
41-
- name: Merge main into demo using -X ours
44+
# Perform the merge using -X ours and add verbose output
45+
# Use continue-on-error to allow the next step to run
46+
- name: Merge main into demo using -X ours (VERBOSE)
47+
run: |
48+
echo "Attempting merge with: git merge --no-ff -X ours --verbose origin/main"
49+
git merge --no-ff -X ours --verbose origin/main -m "Auto-merge main into demo (using -X ours, verbose)"
50+
continue-on-error: true # IMPORTANT: Allow workflow to continue to next step on failure
51+
52+
# *** ADDED: Show Git Status After Merge Attempt ***
53+
# This step will run regardless of merge success/failure IF the previous step used continue-on-error
54+
- name: Show Git Status After Merge Attempt
55+
if: always() # Ensure this runs even if merge succeeded or failed
56+
run: |
57+
echo "--- Git Status after merge attempt ---"
58+
git status --short # Use --short for concise output
59+
echo "--- Files with conflicts (if any) ---"
60+
# List files specifically marked as Unmerged (U)
61+
git diff --name-only --diff-filter=U || echo "No files found with Unmerged status."
62+
63+
# *** IMPORTANT: Check if merge failed before trying to push ***
64+
- name: Check merge result before push
65+
id: merge_check
66+
# Check the exit code of the merge step
4267
run: |
43-
# Using -X ours to force keeping demo's version on all conflicts
44-
git merge --no-ff -X ours origin/main -m "Auto-merge main into demo (using -X ours)"
68+
# Note: This relies on the step ID of the merge step if you named it.
69+
# Adjust 'steps.merge_step_id.outcome' if your merge step has an id:
70+
# For now, we check if status shows unmerged files as a proxy
71+
if git status --short | grep -q '^UU '; then
72+
echo "Merge failed with conflicts. Aborting push."
73+
echo "outcome=failure" >> $GITHUB_OUTPUT
74+
exit 1 # Fail the workflow explicitly
75+
elif git status --short | grep -q '^AA '; then # Added by us, deleted by them
76+
echo "Merge failed with conflicts (AA). Aborting push."
77+
echo "outcome=failure" >> $GITHUB_OUTPUT
78+
exit 1 # Fail the workflow explicitly
79+
elif git status --short | grep -q '^DD '; then # Deleted by both
80+
echo "Merge failed with conflicts (DD). Aborting push."
81+
echo "outcome=failure" >> $GITHUB_OUTPUT
82+
exit 1 # Fail the workflow explicitly
83+
elif git status --short | grep -q '^AU '; then # Added by us, unmerged by them
84+
echo "Merge failed with conflicts (AU). Aborting push."
85+
echo "outcome=failure" >> $GITHUB_OUTPUT
86+
exit 1 # Fail the workflow explicitly
87+
elif git status --short | grep -q '^UA '; then # Unmerged by us, added by them
88+
echo "Merge failed with conflicts (UA). Aborting push."
89+
echo "outcome=failure" >> $GITHUB_OUTPUT
90+
exit 1 # Fail the workflow explicitly
91+
elif git status --short | grep -q '^UD '; then # Unmerged by us, deleted by them
92+
echo "Merge failed with conflicts (UD). Aborting push."
93+
echo "outcome=failure" >> $GITHUB_OUTPUT
94+
exit 1 # Fail the workflow explicitly
95+
elif git status --short | grep -q '^DU '; then # Deleted by us, unmerged by them
96+
echo "Merge failed with conflicts (DU). Aborting push."
97+
echo "outcome=failure" >> $GITHUB_OUTPUT
98+
exit 1 # Fail the workflow explicitly
99+
else
100+
echo "Merge appears successful or conflicts resolved automatically."
101+
echo "outcome=success" >> $GITHUB_OUTPUT
102+
fi
45103
46-
# Push the merge commit (and resolved changes) back to the demo branch
104+
# Push only if the merge succeeded (checked in previous step)
47105
- name: Push changes to demo
106+
if: steps.merge_check.outputs.outcome == 'success'
48107
run: |
49108
git push origin demo

0 commit comments

Comments
 (0)