Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .github/workflows/sync-main-to-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,19 @@ jobs:

git checkout -B $BRANCH_NAME origin/develop

# Tenta o merge. O '|| true' impede que o script pare em caso de conflito.
git merge origin/main --allow-unrelated-histories --no-edit -m "chore: sync main back to develop" || true

# Verifica se há arquivos com conflitos (Unmerged paths)
if git diff --name-only --diff-filter=U | grep .; then
echo "::warning::Merge conflicts detected. Committing conflicted state to be resolved in the PR."
# Adiciona todos os arquivos (incluindo os com marcadores de conflito) e faz o commit.
# Attempt to merge main into the sync branch.
# The 'if' statement handles the exit code, so the step won't fail on merge conflicts.
if git merge origin/main --allow-unrelated-histories --no-edit -m "chore: sync main back to develop"; then
echo "Merge successful without conflicts."
else
echo "::warning::Merge failed, likely due to conflicts. Committing files with conflict markers for manual resolution."
# After a failed merge, files with conflicts are in the working directory.
# We add and commit them to be resolved in the PR.
git add .
git commit -m "chore: sync main with conflicts for manual resolution"
else
echo "Merge completed successfully."
fi

# Continua o fluxo e força o push da branch, seja ela com merge limpo ou com conflitos.
# Push the result, whether it's a clean merge or contains conflicts.
git push --force https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}.git HEAD:$BRANCH_NAME

- name: Create or Update Pull Request
Expand Down