I am trying to check/validate if a git merge
would cause conflicts in GitHub Actions. If the validation is successful, the workflow should actually merge and push the changes, or else the workflow stops.
Merge should be done from master to develop branch.
Part of my code is:
git checkout develop
git merge --no-commit --no-ff master
echo '::set-output name=mergeResult::$?'
git merge --abort
I am reading the value of mergeResult
variable. If 0, proceed with the actual merge; if 1, stop the workflow and echo a message.
In case there are no conflicts, everything works fine. However, when there is a merge conflict, the workflow run fails:
CONFLICT (content): Merge conflict in somefile.txt Automatic merge failed; fix conflicts and then commit the result. Error: Process completed with exit code 1.
My question is: How to avoid this error and let the workflow resume with no failure, regardless of merge conflicts.