pull-request icon indicating copy to clipboard operation
pull-request copied to clipboard

Completing successfully even with failure on hub remote request.

Open loosebazooka opened this issue 4 years ago • 3 comments

When using github job specific permissions and not allowing pr writes, this action should error.

I believe the issue is here: https://github.com/repo-sync/pull-request/blob/master/entrypoint.sh#L84

Using || true will allow this command to succeed even during failure?

To recreate:

  1. Make default action permission in repo = read-only Settings -> Actions -> Workflow permissions -> Read repository contents permission

  2. Run action with repo-sync/pull-request No PR created, but action succeeds with message like

hub pull-request   -b master   -h branchybranchy   --no-edit   -m "some message" || true
Error creating pull request: Forbidden (HTTP 403)
Resource not accessible by integration
  1. Add permission to write pr's into action.yaml
jobs:
  create-pr:
    name: "create some PR"
    permissions:
      pull-requests: write   
    ...
  1. Run action again, with successful pr creation.
hub pull-request   -b master   -h branchybranchy   --no-edit   -m "some message" || true
https://github.com/loosebazooka/testtest/pull/16

loosebazooka avatar Apr 29 '21 16:04 loosebazooka

Thanks for the detailed issue. We didn't want to error when prs failed to be created because you could have permission but there just weren't any changes between the branches. We're open to adding an optional input fail_on_error or similar that does what you described. PR Welcome~

wei avatar Apr 29 '21 17:04 wei

For my own understanding, what do you mean by:

We didn't want to error when prs failed to be created because you could have permission but there just weren't any changes between the branches.

I'm not sure I understand when this use-case will arise?

In the meantime, I'm trying to see if I can get exit codes or structured error output in hub.

loosebazooka avatar Apr 29 '21 18:04 loosebazooka

The action let's you define source and destination branches. There are cases when someone might run this on a schedule and ignore errors when a pr can't be created due to lack of changes.

wei avatar Apr 29 '21 18:04 wei

Thank you for opening this issue. Per the updated README, we are in process of archiving this repository, and encourage using gh pr create directly in your workflows instead.

heiskr avatar Jun 12 '23 17:06 heiskr