added new 8 #125
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workflow from the previous step - attempting merge and resolving conflicts | |
name: Sync Demo Branch (Merge & Resolve) | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
sync-demo-branch: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout demo branch | |
- name: Checkout demo branch | |
uses: actions/checkout@v4 | |
with: | |
ref: 'demo' | |
token: ${{ secrets.DEMO_UPDATE_PAT }} | |
fetch-depth: 0 # Needed for merge | |
# Configure Git User | |
- name: Configure Git User | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "actions-bot@github.com" | |
# Disable autocrlf | |
- name: Disable autocrlf | |
run: git config --global core.autocrlf false | |
# Fetch origin | |
- name: Fetch origin | |
run: git fetch origin | |
# Attempt Merge | |
- name: Attempt Merge main into demo using -X ours | |
id: merge_attempt | |
run: | | |
echo "Attempting merge with: git merge --no-ff -X ours origin/main" | |
git merge --no-ff -X ours origin/main -m "Auto-merge main into demo" | |
continue-on-error: true | |
# Resolve Conflicts Favoring 'ours' | |
- name: Resolve Conflicts Favoring 'ours' | |
if: steps.merge_attempt.outcome == 'failure' | |
run: | | |
echo "Merge failed, attempting to resolve conflicts favouring 'ours'..." | |
git diff --name-only --diff-filter=U > conflicted_files.txt | |
if [ -s conflicted_files.txt ]; then | |
echo "Conflicting files found:" | |
cat conflicted_files.txt | |
echo "Checking out 'ours' version for conflicting files..." | |
xargs -r -a conflicted_files.txt git checkout --ours -- | |
echo "Adding resolved files..." | |
xargs -r -a conflicted_files.txt git add -- | |
echo "Committing resolved merge..." | |
git commit -m "Auto-merge main into demo (Conflicts resolved favoring demo)" | |
echo "Conflicts resolved and committed." | |
else | |
echo "Merge failed, but no conflicting files found by 'git diff --diff-filter=U'. Aborting." | |
exit 1 | |
fi | |
# Check Status After Resolution Attempt (Safety Check) | |
- name: Check Status After Resolution Attempt | |
if: steps.merge_attempt.outcome == 'failure' | |
run: | | |
echo "--- Git Status after conflict resolution attempt ---" | |
git status --short | |
if git diff --name-only --diff-filter=U | read; then | |
echo "ERROR: Unmerged files still exist after resolution attempt!" | |
exit 1 | |
fi | |
# Push changes to demo (no force needed) | |
- name: Push changes to demo | |
run: | | |
echo "Pushing changes to demo..." | |
git push origin demo |