Skip to content

Commit

Permalink
rebase but leave last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zen0bit committed Jan 16, 2025
1 parent 6d97237 commit 5e27f7e
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/test-apps.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Test random 💯"
name: "Test random 💯 2.0 T"

env:
TERM: xterm
Expand Down Expand Up @@ -48,11 +48,18 @@ jobs:
else
git checkout testing
fi
last_commit_hash=$(git log -n 1 --format=%H)
git fetch origin main
if [[ $(git rev-list HEAD...origin/main --count) -gt 0 ]]; then
echo "Changes detected between 'main' and 'testing'. Rebasing..."
git merge origin/main --no-edit
git push origin testing
git rebase origin/main
if [ $? -ne 0 ]; then
echo "Rebase failed. Attempting to resolve conflicts."
git rebase --abort
exit 1
fi
git cherry-pick $last_commit_hash
git push origin testing --force-with-lease
fi
if [[ $GITHUB_REF == refs/pull/* ]]; then
echo "This is Pull Request. No saving results."
Expand Down Expand Up @@ -298,8 +305,17 @@ jobs:
if [[ $GITHUB_REF == refs/pull/* ]]; then
echo "This is Pull Request. No saving results."
else
git commit -m "update results"
git push origin testing
last_commit_branch=$(git rev-parse --abbrev-ref HEAD)
last_commit_message=$(git log -1 --pretty=%B)
if [[ "$last_commit_branch" == "main" || "$last_commit_message" == *"merge main"* ]]; then
echo "Last commit is from main. Creating a new commit."
git commit -m "update results"
git push origin testing
else
echo "Last commit is from testing. Amending last commit."
git commit --amend --no-edit --date "$(date)"
git push origin testing --force-with-lease
fi
fi
fi
Expand Down

0 comments on commit 5e27f7e

Please sign in to comment.