Skip to content

Commit 08713f0

Browse files
feat: add pull_request_created output to track PR status (#294)
1 parent fb221ac commit 08713f0

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ This action has the following outputs:
226226

227227
- `pull_request_url`: The URL of the pull request created by the workflow
228228
- `pull_request_number`: The number of the pull request created by the workflow
229+
- `pull_request_created`: Whether a new pull request was created (`true`) or an existing one was found (`false`)
229230

230231
## Permissions
231232

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ outputs:
191191
description: 'The URL of the pull request created by the workflow'
192192
pull_request_number:
193193
description: 'The number of the pull request created by the workflow'
194+
pull_request_created:
195+
description: 'Whether a new pull request was created (true) or an existing one was found (false)'
194196

195197
runs:
196198
using: docker

docs/EXAMPLES.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,13 @@ strategy:
461461

462462
## Outputs
463463

464-
### `pull_request_url`, `pull_request_number`
464+
### `pull_request_url`, `pull_request_number`, `pull_request_created`
465465

466-
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.
466+
There is a possibility to get the URL, number, and creation status of the Pull Request. You can use it in the next steps of your workflow.
467+
468+
- `pull_request_url`: The URL of the pull request created by the workflow
469+
- `pull_request_number`: The number of the pull request created by the workflow
470+
- `pull_request_created`: Whether a new pull request was created (`true`) or an existing one was found (`false`)
467471

468472
```yaml
469473
# ...
@@ -488,6 +492,10 @@ There is a possibility to get the URL or number of the created Pull Request. You
488492
run: gh pr --repo $GITHUB_REPOSITORY review ${{ steps.crowdin-download.outputs.pull_request_url }} --approve
489493
env:
490494
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
495+
496+
- name: Notify about new PR
497+
if: steps.crowdin-download.outputs.pull_request_created == 'true'
498+
run: echo "A new pull request was created: ${{ steps.crowdin-download.outputs.pull_request_url }}"
491499
```
492500

493501
## Tips and Tricks

entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Default values for action outputs
44
echo "pull_request_url=" >> $GITHUB_OUTPUT
55
echo "pull_request_number=" >> $GITHUB_OUTPUT
6+
echo "pull_request_created=false" >> $GITHUB_OUTPUT
67

78
if [ "$INPUT_DEBUG_MODE" = true ] || [ -n "$RUNNER_DEBUG" ]; then
89
echo '---------------------------'
@@ -160,6 +161,8 @@ create_pull_request() {
160161
exit 1
161162
fi
162163

164+
echo "pull_request_created=true" >> $GITHUB_OUTPUT
165+
163166
if [ -n "$INPUT_PULL_REQUEST_LABELS" ]; then
164167
PULL_REQUEST_LABELS=$(echo "[\"${INPUT_PULL_REQUEST_LABELS}\"]" | sed 's/, \|,/","/g')
165168

0 commit comments

Comments
 (0)