A GitHub Action that executes an arbitrary command and captures its output, including stdout, stderr, and exit code. The action streams command output in real-time and forwards signals to the command.
- Execute any single command
- Capture standard output, standard error, and exit code as action outputs
- Stream output in real-time to the workflow logs
- Forward signals (SIGINT, SIGTERM, SIGQUIT, SIGHUP, SIGPIPE, SIGABRT) to the running command
- Commands are executed directly without a shell (no shell operators like
|,&&,>)
IMPORTANT: This action executes commands directly without a shell. This
means shell features like pipes (|), redirects (>), command chaining (&&,
||), and glob expansion (*) are not available.
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Execute Command
id: exec
uses: retailnext/exec-action@main
with:
command: 'echo "Hello World"'
- name: Print Output
run: |
echo "Exit Code: ${{ steps.exec.outputs.exit_code }}"
echo "Stdout: ${{ steps.exec.outputs.stdout }}"
echo "Stderr: ${{ steps.exec.outputs.stderr }}"Required The command to execute with its arguments.
The command is executed directly without a shell. Executables in your PATH can
be used without specifying the full path (e.g., npm, ls, git).
Optional Exit codes that should be treated as success. Can be individual
codes (e.g., "0,1,2") or ranges (e.g., "0-2,5,10-15"). Default is "0".
This is useful when your command may exit with non-zero codes that should still be considered successful. For example, some linters return specific exit codes for warnings vs errors, or you may want to accept multiple exit codes as valid outcomes.
The standard output of the executed command.
The standard error of the executed command.
The exit code of the executed command (as a string).
- name: Build Project
id: build
uses: retailnext/exec-action@main
with:
command: 'npm run build'
- name: Check Build Status
if: steps.build.outputs.exit_code == '0'
run: echo "Build succeeded!"- name: Run Command
id: run
uses: retailnext/exec-action@main
with:
command: 'some-command-that-might-fail'
continue-on-error: true
- name: Handle Failure
if: steps.run.outputs.exit_code != '0'
run: |
echo "Command failed with exit code ${{ steps.run.outputs.exit_code }}"
echo "Error output: ${{ steps.run.outputs.stderr }}"- name: Run Linter
uses: retailnext/exec-action@main
with:
command: 'eslint .'
# Treat exit codes 0 (no issues) and 1 (warnings only) as success
success_exit_codes: '0,1'- name: Run Tests
uses: retailnext/exec-action@main
with:
command: 'pytest'
# Treat exit codes 0-5 as success
success_exit_codes: '0-5'- name: Complex Command
uses: retailnext/exec-action@main
with:
command: 'some-tool --check'
# Accept 0, any code from 10-15, and 20 as success
success_exit_codes: '0,10-15,20'