How to use GitHub CLI to automatically create a pull request from a feature branch after a successful CI build?
Can someone help me understand I'm maintaining legacy code that I'm trying to automate my workflow by using GitHub CLI to create a pull request from a feature branch once my CI builds successfully. I have my feature branch named `feature/new-feature` and my main branch is `main`. I am using GitHub Actions for CI/CD, and I want to trigger the PR creation only if the build passes. I'm using the following GitHub Actions workflow: ```yaml name: CI on: push: branches: - feature/new-feature jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '14' - name: Install dependencies run: npm install - name: Run tests run: npm test - name: Create Pull Request if: success() run: gh pr create --base main --head feature/new-feature --title "New Feature" --body "This PR adds a new feature" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` However, I am working with the following behavior when the `gh pr create` command runs: ``` behavior: Invalid request: No commits between feature/new-feature and main ``` This behavior suggests that the workflow does not recognize any changes between the branches, even though I can see the changes in my feature branch. I've tried to resolve it by ensuring I have committed my changes to the `feature/new-feature` branch before the CI runs, and I've double-checked the branch names for typos. I'm also certain that `GITHUB_TOKEN` is set properly and has the necessary permissions. What could be going wrong here? Is there something I'm missing in my setup? Any advice would be greatly appreciated! I'm working on a REST API that needs to handle this. I'd really appreciate any guidance on this. What's the correct way to implement this? This is for a web app running on CentOS. What's the correct way to implement this?