workflow: first check if merge is necessary

This commit is contained in:
Julian Mutter 2025-03-22 08:42:55 +01:00
parent b0b6ef6bba
commit 2ac3af7a53

View File

@ -23,11 +23,26 @@ jobs:
git config user.email "actions@gitea.local"
- name: Merge main branch
shell: bash
run: |
git merge --squash origin/main
# solve merge conflict by taking flake.lock from main
git checkout origin/main -- flake.lock
git commit -m "Merge main branch squashed $(date -I)"
commits_ahead=$(git rev-list --count HEAD..origin/main)
echo "Commits ahead: $commits_ahead"
git log --oneline -5
echo "----------"
git log --oneline -5 origin/main
if [ $commits_ahead -ne 0 ]
then
git fetch origin
git merge --squash origin/main
git push --force-with-lease
# solve potential merge conflict by taking flake.lock from main
git checkout origin/main -- flake.lock
git commit -m "Merge main branch squashed $(date -I)"
else
echo "Merge not necessary"
fi
- name: Set up Nix
uses: cachix/install-nix-action@v31
@ -39,7 +54,7 @@ jobs:
shell: bash
run: |
git add flake.lock
if git diff --cached --quiet; then
if git diff --quiet; then
echo "No changes to commit."
else
git commit -m "Update flake.lock $(date -I)"