Skip to content

Commit 7334732

Browse files
feat: add command_output for arbitrary CLI commands (#302)
1 parent d3c6815 commit 7334732

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ You can also run any other Crowdin CLI command by specifying the `command` and `
216216
with:
217217
command: 'pre-translate'
218218
command_args: '-l uk --method tm --branch main'
219+
220+
# Access the command output in subsequent steps (optional)
221+
- name: Use command output
222+
run: echo "${{ steps.crowdin.outputs.command_output }}"
219223
```
220224

221225
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:
227231
- `pull_request_url`: The URL of the pull request created by the workflow
228232
- `pull_request_number`: The number of the pull request created by the workflow
229233
- `pull_request_created`: Whether a new pull request was created (`true`) or an existing one was found (`false`)
234+
- `command_output`: The output of the Crowdin CLI command (only available when using the `command` input)
230235

231236
## Permissions
232237

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ outputs:
193193
description: 'The number of the pull request created by the workflow'
194194
pull_request_created:
195195
description: 'Whether a new pull request was created (true) or an existing one was found (false)'
196+
command_output:
197+
description: 'The output of the Crowdin CLI command when using the command input'
196198

197199
runs:
198200
using: docker

entrypoint.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
echo "pull_request_url=" >> $GITHUB_OUTPUT
55
echo "pull_request_number=" >> $GITHUB_OUTPUT
66
echo "pull_request_created=false" >> $GITHUB_OUTPUT
7+
echo "command_output=" >> $GITHUB_OUTPUT
78

89
if [ "$INPUT_DEBUG_MODE" = true ] || [ -n "$RUNNER_DEBUG" ]; then
910
echo '---------------------------'
@@ -364,7 +365,15 @@ fi
364365

365366
if [ -n "$INPUT_COMMAND" ]; then
366367
echo "RUNNING COMMAND crowdin $INPUT_COMMAND $INPUT_COMMAND_ARGS"
367-
crowdin $INPUT_COMMAND $INPUT_COMMAND_ARGS
368+
369+
# Capture command output while still displaying it
370+
CROWDIN_OUTPUT=$(crowdin $INPUT_COMMAND $INPUT_COMMAND_ARGS)
371+
echo "$CROWDIN_OUTPUT"
372+
373+
# Write multiline output to GITHUB_OUTPUT using heredoc delimiter
374+
echo "command_output<<CROWDIN_EOF" >> $GITHUB_OUTPUT
375+
echo "$CROWDIN_OUTPUT" >> $GITHUB_OUTPUT
376+
echo "CROWDIN_EOF" >> $GITHUB_OUTPUT
368377

369378
# in this case, we don't need to continue executing any further default behavior
370379
exit 0

0 commit comments

Comments
 (0)