diff --git a/.github/workflows/build-push-next.yml b/.github/workflows/build-push-next.yml index 35d216f..d5093dd 100644 --- a/.github/workflows/build-push-next.yml +++ b/.github/workflows/build-push-next.yml @@ -21,6 +21,20 @@ jobs: repository: eelab-dev/EEcircuit ref: next # Checkout the "next" branch + # Delete bot branch if it exists + - name: Delete 'bot' branch if it exists + run: | + if git show-ref --verify --quiet refs/heads/bot; then + git branch -D bot + fi + + # Create new 'bot' branch from 'next' + - name: Create new 'bot' branch + run: | + git checkout next + git checkout -b bot + + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -65,22 +79,28 @@ jobs: name: playwright-report path: playwright-report/ retention-days: 30 - - # Check if 'bot' branch exists and delete it if it does - - name: Delete 'bot' branch if it exists - run: git branch -a | grep -q bot && git branch -D bot || echo "Branch 'bot' not found" - - # Create new 'bot' branch from 'next' - - name: Create new 'bot' branch + + + # First handle any uncommitted changes + - name: Stage and commit any changes run: | - git checkout next - git checkout -b bot + git add . + git diff --staged --quiet || git commit -m "Automated: Stage uncommitted changes" + - # Create a Pull Request + # Create Pull Request only if there are differences - name: Create Pull Request - run: gh pr create --base next --head bot --title "Update from bot branch" --body "Automated pull request to merge changes from the bot branch to next." + run: | + if [ $(git rev-list --count next..bot) -gt 0 ]; then + gh pr create \ + --base next \ + --head bot \ + --title "Update from bot branch" \ + --body "Automated pull request to merge changes from the bot branch to next." + else + echo "No changes to create PR for" + fi -