devops-infra / action-pull-request

GitHub Action that will create a pull request from the current branch
https://christophshyper.github.io/
MIT License
74 stars 21 forks source link

Issues with multiple PRs opened #98

Closed bentonjimmy closed 2 years ago

bentonjimmy commented 2 years ago

:memo: Issues when opening multiple PRs in a single workflow

In my workflow, I am attempting to use this component to open a PR to branches within the repo. I'm looking to open a PR that updates two different branches with the main branch. What actually happens, thought, is that one PR is opened and the second attempt to open a PR results in the component PATCH-ing the first PR. I expected this to open two different PRs to two different branches.

The workflow I'm using is below. I originally tried this with a matrix and had the same issue.



on: 
  workflow_dispatch:
  repository_dispatch:
    types: [update-environments]

jobs:
  continuous-integration-1:
      name: "Upper Environment Pull Requests - devex-dev"
      runs-on: ubuntu-latest
      steps:
        - name: Checkout s2-env-configuration
          uses: actions/checkout@v3
          with:
            fetch-depth: 0

        - name: Create pull request to s2-env-configuration devex-dev branch
          uses: devops-infra/action-pull-request@v0.5.0
          with:
            github_token: ${{ github.token }}
            allow_no_diff: true
            assignee: bentonjimmy
            source_branch: main
            target_branch: devex-dev
            title: "feat(deployment): updated devex-dev to latest s2-deployments tag"
            body: "Updated branch to latest s2-deployments tag"

  continuous-integration-2:
      name: "Upper Environment Pull Requests - demo-dev"
      runs-on: ubuntu-latest
      steps:
        - name: Checkout s2-env-configuration
          uses: actions/checkout@v3
          with:
            fetch-depth: 0
        - name: Create pull request to s2-env-configuration demo-dev branch
          uses: devops-infra/action-pull-request@v0.5.0
          with:
            github_token: ${{ github.token }}
            allow_no_diff: true
            assignee: bentonjimmy
            source_branch: main
            target_branch: demo-dev
            title: "feat(deployment): updated demo-dev to latest s2-deployments tag"
            body: "Updated branch to latest s2-deployments tag" ```

## :warning: Checklist
* [x] Provided a clear and concise description of what the issue is.
* [x] Given a clear and concise description of what is expected.
* [x] Proposed a clear and concise description of any alternative solutions or other features.
* [x] Added any other context or screenshots about the feature request.
* [x] Associated pull request has been already created and link was provided.

*Check [CONTRIBUTING.md][contributing] and [CODE_OF_CONDUCT.md][code] for more information*

[contributing]: https://github.com/devops-infra/.github/blob/master/CONTRIBUTING.md
[code]: https://github.com/devops-infra/.github/blob/master/CODE_OF_CONDUCT.md
bentonjimmy commented 2 years ago

The issue seems to be with this line: https://github.com/devops-infra/action-pull-request/blob/master/entrypoint.sh#L99 This line is checking if the source/head has any other PR open where it is the source/head. If it retrieves a value, this value is later used for PATCH-ing the PR.
I think this line of code should be checking for a pre-existing PR that has the same source/head and target/base.

bentonjimmy commented 2 years ago

Opened a PR with the change: https://github.com/devops-infra/action-pull-request/pull/100

ChristophShyper commented 2 years ago

Thank you for this change :)

berndgevers commented 1 year ago

Had the same issue with v0.4.2.

Thanks for this fix, really helped us when we were creating new Actions again.