https://github.com/mathiasvr/command-output
GitHub action that runs a command and store its output
https://github.com/mathiasvr/command-output
actions github-actions
Last synced: 8 months ago
JSON representation
GitHub action that runs a command and store its output
- Host: GitHub
- URL: https://github.com/mathiasvr/command-output
- Owner: mathiasvr
- License: mit
- Created: 2021-12-15T21:39:56.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-26T18:29:13.000Z (about 2 years ago)
- Last Synced: 2025-10-28T04:28:22.572Z (8 months ago)
- Topics: actions, github-actions
- Language: JavaScript
- Homepage:
- Size: 92.8 KB
- Stars: 46
- Watchers: 2
- Forks: 10
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Command Output
A `run` alternative that stores command output in a variable.
## Inputs
### `run`
**Required** The command to run.
### `shell`
The shell used to run command.
## Outputs
### `stdout`
The output of the command written to stdout.
### `stderr`
The output of the command written to stderr.
## Example usage
#### Store today's date in variable
```yaml
steps:
- name: Get today's date
uses: mathiasvr/command-output@v2.0.0
id: today
with:
run: date +'%Y-%m-%d'
- run: echo Today is ${{ steps.today.outputs.stdout }}
```
#### Use stdout and stderr output as condition
```yaml
steps:
- name: Read file if it exists?
uses: mathiasvr/command-output@v2.0.0
continue-on-error: true
id: cmd
with:
run: cat unknown.txt
- run: echo Command succeeded
if: ${{ steps.cmd.outputs.stdout }}
- run: echo Command failed
if: ${{ steps.cmd.outputs.stderr }}
```