diff --git a/README.md b/README.md index aa997c0..f8010c6 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,7 @@ 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 +- `pull_request_created`: Whether a new pull request was created (`true`) or an existing one was found (`false`) ## Permissions diff --git a/action.yml b/action.yml index 6befdd7..f74cfd7 100644 --- a/action.yml +++ b/action.yml @@ -191,6 +191,8 @@ outputs: 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' + pull_request_created: + description: 'Whether a new pull request was created (true) or an existing one was found (false)' runs: using: docker diff --git a/docs/EXAMPLES.md b/docs/EXAMPLES.md index 375f985..c2e83ac 100644 --- a/docs/EXAMPLES.md +++ b/docs/EXAMPLES.md @@ -461,9 +461,13 @@ strategy: ## Outputs -### `pull_request_url`, `pull_request_number` +### `pull_request_url`, `pull_request_number`, `pull_request_created` -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. +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. + +- `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 +- `pull_request_created`: Whether a new pull request was created (`true`) or an existing one was found (`false`) ```yaml # ... @@ -488,6 +492,10 @@ There is a possibility to get the URL or number of the created Pull Request. You run: gh pr --repo $GITHUB_REPOSITORY review ${{ steps.crowdin-download.outputs.pull_request_url }} --approve env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + +- name: Notify about new PR + if: steps.crowdin-download.outputs.pull_request_created == 'true' + run: echo "A new pull request was created: ${{ steps.crowdin-download.outputs.pull_request_url }}" ``` ## Tips and Tricks diff --git a/entrypoint.sh b/entrypoint.sh index 270d67c..36ce8b9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,6 +3,7 @@ # Default values for action outputs echo "pull_request_url=" >> $GITHUB_OUTPUT echo "pull_request_number=" >> $GITHUB_OUTPUT +echo "pull_request_created=false" >> $GITHUB_OUTPUT if [ "$INPUT_DEBUG_MODE" = true ] || [ -n "$RUNNER_DEBUG" ]; then echo '---------------------------' @@ -160,6 +161,8 @@ create_pull_request() { exit 1 fi + echo "pull_request_created=true" >> $GITHUB_OUTPUT + if [ -n "$INPUT_PULL_REQUEST_LABELS" ]; then PULL_REQUEST_LABELS=$(echo "[\"${INPUT_PULL_REQUEST_LABELS}\"]" | sed 's/, \|,/","/g')