diff --git a/README.md b/README.md index f8010c6..b865bd1 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,10 @@ You can also run any other Crowdin CLI command by specifying the `command` and ` with: command: 'pre-translate' command_args: '-l uk --method tm --branch main' + +# Access the command output in subsequent steps (optional) +- name: Use command output + run: echo "${{ steps.crowdin.outputs.command_output }}" ``` To see the full list of available commands, visit the [official documentation](https://crowdin.github.io/crowdin-cli/). @@ -227,6 +231,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`) +- `command_output`: The output of the Crowdin CLI command (only available when using the `command` input) ## Permissions diff --git a/action.yml b/action.yml index f74cfd7..9f4bc15 100644 --- a/action.yml +++ b/action.yml @@ -193,6 +193,8 @@ outputs: 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)' + command_output: + description: 'The output of the Crowdin CLI command when using the command input' runs: using: docker diff --git a/entrypoint.sh b/entrypoint.sh index 36ce8b9..e8734b3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,6 +4,7 @@ echo "pull_request_url=" >> $GITHUB_OUTPUT echo "pull_request_number=" >> $GITHUB_OUTPUT echo "pull_request_created=false" >> $GITHUB_OUTPUT +echo "command_output=" >> $GITHUB_OUTPUT if [ "$INPUT_DEBUG_MODE" = true ] || [ -n "$RUNNER_DEBUG" ]; then echo '---------------------------' @@ -364,7 +365,15 @@ fi if [ -n "$INPUT_COMMAND" ]; then echo "RUNNING COMMAND crowdin $INPUT_COMMAND $INPUT_COMMAND_ARGS" - crowdin $INPUT_COMMAND $INPUT_COMMAND_ARGS + + # Capture command output while still displaying it + CROWDIN_OUTPUT=$(crowdin $INPUT_COMMAND $INPUT_COMMAND_ARGS) + echo "$CROWDIN_OUTPUT" + + # Write multiline output to GITHUB_OUTPUT using heredoc delimiter + echo "command_output<> $GITHUB_OUTPUT + echo "$CROWDIN_OUTPUT" >> $GITHUB_OUTPUT + echo "CROWDIN_EOF" >> $GITHUB_OUTPUT # in this case, we don't need to continue executing any further default behavior exit 0