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

Add pull request number as an output #104

Closed TomOConnor95 closed 2 years ago

TomOConnor95 commented 2 years ago

:memo: Brief description

description of what the issue is.

The action only has an output of url (pull request url) If you want to perform additional additional actions after this action it is very helpful to know the number of the pull request, not the full URL. (For my use-case I want to run peter-evans/enable-pull-request-automerge@v2 afterwards)

description of what is expected.

An additional output to be provided, with name pull-request-number

description of any alternative solutions or other features.

For now I am taking the pull request url, and parsing the pull request number from it. Not a dealbreaker, but a bit fiddly to do. Plus if the url scheme for github pull requests ever changes, I'd have to adjust my logic

Here's what I'm doing to extract the PR number

- name: Get Pull Request Number
        id: prNumber
        run: |
          regex="\/pull\/([0-9]+)"
          if [[ ${{ steps.create-pull-request.outputs.url }} =~ $regex ]]
              then
                  echo "::set-output name=prNumber::${BASH_REMATCH[1]}"
              else
                  echo "$pullRequestNumber is not valid" >&2
              fi

:warning: Checklist

Check CONTRIBUTING.md and CODE_OF_CONDUCT.md for more information

ChristophShyper commented 2 years ago

Hello. Thank you for taking an interest in my action and improving it. I've just added pr_number to outputs in v0.5.2.

TomOConnor95 commented 2 years ago

Amazing! Thanks so much! 🎉🎉🎉

On 3 Nov 2022, at 10:04, Krzysztof Szyper @.***> wrote:



Hello. Thank you for taking an interest in my action and improving it. I've just added pr_number to outputs in v0.5.2.

— Reply to this email directly, view it on GitHubhttps://github.com/devops-infra/action-pull-request/issues/104#issuecomment-1301810732, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGMAILKVVZGNUIMHYDAU5H3WGN5ZVANCNFSM6AAAAAARTGC7NI. You are receiving this because you authored the thread.Message ID: @.***>

thepeachkhoukha commented 1 year ago

Hello, I am using your action to create a pr, (it was successfully created) however, it seems like the pr_number is empty

Screenshot 2022-12-13 at 11 39 16

can you please tell me if I am doing something wrong?

Screenshot 2022-12-13 at 11 41 32
ChristophShyper commented 1 year ago

Hello @whiteKhoukha . Sorry I missed your post. This has been fixed in devops-infra/action-pull-request@v0.5.5