workflow: first check if merge is necessary
This commit is contained in:
parent
b0b6ef6bba
commit
2ac3af7a53
@ -23,11 +23,26 @@ jobs:
|
|||||||
git config user.email "actions@gitea.local"
|
git config user.email "actions@gitea.local"
|
||||||
|
|
||||||
- name: Merge main branch
|
- name: Merge main branch
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
git merge --squash origin/main
|
commits_ahead=$(git rev-list --count HEAD..origin/main)
|
||||||
# solve merge conflict by taking flake.lock from main
|
echo "Commits ahead: $commits_ahead"
|
||||||
git checkout origin/main -- flake.lock
|
git log --oneline -5
|
||||||
git commit -m "Merge main branch squashed $(date -I)"
|
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
|
- name: Set up Nix
|
||||||
uses: cachix/install-nix-action@v31
|
uses: cachix/install-nix-action@v31
|
||||||
@ -39,7 +54,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
git add flake.lock
|
git add flake.lock
|
||||||
if git diff --cached --quiet; then
|
if git diff --quiet; then
|
||||||
echo "No changes to commit."
|
echo "No changes to commit."
|
||||||
else
|
else
|
||||||
git commit -m "Update flake.lock $(date -I)"
|
git commit -m "Update flake.lock $(date -I)"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user