Skip to content

Commit

Permalink
feat: add the 'pull_request_number' output (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar authored Feb 13, 2024
1 parent 38c22fc commit c953b17
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- [Separate PRs for each target language](#separate-prs-for-each-target-language)
- [Checking out multiple branches in a single workflow](#checking-out-multiple-branches-in-a-single-workflow)
- [Outputs](#outputs)
- [`pull_request_url`](#pull_request_url)
- [`pull_request_url`, `pull_request_number`](#pull_request_url-pull_request_number)
- [Triggers](#triggers)
- [Cron schedule](#cron-schedule)
- [Manually](#manually)
Expand Down Expand Up @@ -451,9 +451,9 @@ strategy:

## Outputs

### `pull_request_url`
### `pull_request_url`, `pull_request_number`

There is a possibility to get the URL of the created Pull Request. You can use it in the next steps of your workflow.
There is a possibility to get the URL or number of the created Pull Request. You can use it in the next steps of your workflow.

```yaml
# ...
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ When the workflow runs, the real values of your token and project ID will be inj
This action has the following outputs:

- `pull_request_url`: The URL of the pull request created by the workflow
- `pull_request_number`: The number of the pull request created by the workflow

## Permissions

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ inputs:
outputs:
pull_request_url:
description: 'The URL of the pull request created by the workflow'
pull_request_number:
description: 'The number of the pull request created by the workflow'

runs:
using: docker
Expand Down
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Default values for action outputs
echo "pull_request_url=" >> $GITHUB_OUTPUT
echo "pull_request_number=" >> $GITHUB_OUTPUT

if [ "$INPUT_DEBUG_MODE" = true ] || [ -n "$RUNNER_DEBUG" ]; then
echo '---------------------------'
Expand Down Expand Up @@ -93,6 +94,7 @@ create_pull_request() {
if [[ $auth_status -eq 403 || "$auth_status" -eq 401 ]] ; then
echo "FAILED TO AUTHENTICATE USING 'GITHUB_TOKEN' CHECK TOKEN IS VALID"
echo "pull_request_url=" >> $GITHUB_OUTPUT
echo "pull_request_number=" >> $GITHUB_OUTPUT
exit 1
fi

Expand Down Expand Up @@ -139,6 +141,10 @@ create_pull_request() {
echo "pull_request_url=$PULL_REQUESTS_URL" >> $GITHUB_OUTPUT
fi

if [ -n "$PULL_REQUESTS_NUMBER" ]; then
echo "pull_request_number=$PULL_REQUESTS_NUMBER" >> $GITHUB_OUTPUT
fi

if [ "$PULL_REQUESTS_URL" = null ]; then
echo "FAILED TO CREATE PULL REQUEST"
echo "RESPONSE: ${PULL_RESPONSE}"
Expand Down

0 comments on commit c953b17

Please sign in to comment.