Skip to content

actions/create-and-merge-pull-request is failing when pull request exists already #265

@neilime

Description

@neilime

Describe the bug

When using hoverkraft-tech/ci-github-common/actions/create-and-merge-pull-request, if the a pull request exist already, it sometimes fails: Error: Cannot read properties of undefined (reading 'number')

There is a flaw in the action peter-evans/create-pull-request: https://github.com/peter-evans/create-pull-request/blob/25575a12f382fb9c68692ffce1174138b61417d7/src/github-helper.ts#L123

To Reproduce

Create a pull request with the proper branch name, the call the hoverkraft-tech/ci-github-common/actions/create-and-merge-pull-request

Expected behavior

When this case occurs it should retry to create the pull request

Screenshots

Run peter-evans/create-pull-request@v6.0.0
  with:
    token: ***
    signoff: true
    base: main
    delete-branch: true
    branch: feat/deploy-www-pr-751
    title: feat(www): deploy 3.13.0-pr-751-e7b1d433 to review-apps
    body: Deploy 3.13.0-pr-751-e7b1d433 to review-apps
    commit-message: feat(www): deploy 3.13.0-pr-751-e7b1d433 to review-apps"
  
  [skip ci]
  
    author: github-actions[bot] <41898[28](https://github.com/aircorsica/argo-app-of-the-apps/actions/runs/8830909931/job/24245047467#step:9:33)2+github-actions[bot]@users.noreply.github.com>
    committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    draft: false
Prepare git configuration
Determining the base and head repositories
Pull request branch target repository set to aircorsica/argo-app-of-the-apps
Configuring credential for HTTPS authentication
Checking the base repository state
Pull request branch to create or update set to 'feat/deploy-www-pr-751'
Configuring the committer and author
Create or update the pull request branch
Pushing pull request branch to 'origin/feat/deploy-www-pr-7[51](https://github.com/aircorsica/argo-app-of-the-apps/actions/runs/8830909931/job/24245047467#step:9:59)'
Create or update the pull request
Restore git configuration*
  Attempting creation of pull request
  A pull request already exists for aircorsica:feat/deploy-www-pr-751
  Fetching existing pull request
  Attempting update of pull request
  Error: Cannot read properties of undefined (reading 'number')

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions