Skip to content

Commit

Permalink
Handle reusing a pull request
Browse files Browse the repository at this point in the history
We were hitting an error where gh pr create would fail when a PR already
existed for a branch. This is unfortunately not an easy case to handle,
as the tool isn't very smart. See:

    cli/cli#5792

To work-around that limitation, we first try to edit the PR. If that
fails, we create a new PR. However, I've noticed edit will succeed for
closed PRs (which makes sense), so we try to reopen after edit, which
succeeds if the PR is already open.

This is not working 100% as intended, as gh pr reopen currently fails
to actually reopen closed PRs. The end result is reasonable, though, as
we get a newly created PR when the previous one was closed.
  • Loading branch information
Gustavo Noronha Silva committed Oct 28, 2022
1 parent 30288e4 commit 45abc4e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
if: env.DID_IMPORT == '1'
run: |
echo ${{ secrets.GH_TOKEN }} | gh auth login --with-token
gh pr create --fill -B main -H ${{ env.BRANCH_NAME }}
gh pr edit ${{ env.BRANCH_NAME }} -b '${{ env.PR_BODY }}' -t '${{ env.PR_TITLE }}' && gh pr reopen ${{ env.BRANCH_NAME }} || gh pr create --fill -B main -H ${{ env.BRANCH_NAME }}
- name: Upload PDFs
if: env.DID_IMPORT == '1'
Expand Down

0 comments on commit 45abc4e

Please sign in to comment.