Skip to content

Commit

Permalink
feat: Add disable-command-traces input option
Browse files Browse the repository at this point in the history
  • Loading branch information
jetexe committed Oct 7, 2024
1 parent d417006 commit e8fbf33
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,12 @@ jobs:
with:
run: echo "Use job.status variable to check the job status (success, failure or cancelled)"
post: if [ "${{ job.status }}" = "success" ]; then echo "Test passed"; else exit 1; fi

- name: Disable command trace
uses: ./
with:
post: |
echo "::group::Group logs"
echo "This is a group"
echo "::endgroup::"
disable-command-trace: 'true'
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ More examples can be found in the [tests](./.github/workflows/tests.yml).
The following inputs can be used as `step.with` keys:

| Name | Type | Default | Required | Description |
|---------------------|:------------------:|:-------:|:--------:|----------------------------------------------------------------------------|
| `run` | `string` or `list` | | no | A commands that needs to be run in place |
| `post` | `string` or `list` | | yes | A commands that needs to be run once a workflow job has ended |
| `working-directory` | `string` | | no | A working directory from which the command needs to be run |
| `shell` | `string` | `bash` | no | A shell to use for executing `run` commands |
| `post-shell` | `string` | | no | A shell to use for executing `post` commands. Defaults to value of `shell` |
| Name | Type | Default | Required | Description |
|-------------------------|:------------------:|:-------:|:--------:|----------------------------------------------------------------------------|
| `run` | `string` or `list` | | no | A commands that needs to be run in place |
| `post` | `string` or `list` | | yes | A commands that needs to be run once a workflow job has ended |
| `working-directory` | `string` | | no | A working directory from which the command needs to be run |
| `shell` | `string` | `bash` | no | A shell to use for executing `run` commands |
| `post-shell` | `string` | | no | A shell to use for executing `post` commands. Defaults to value of `shell` |
| `disable-command-trace` | `boolean` | `false` | no | Disable command trace for `run` and `post` commands |

## Releasing

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ inputs:
post-shell:
description: A shell to use for executing post commands. Defaults to value of shell input
required: false
disable-command-trace:
description: Disable command trace for run and post commands
required: false
default: 'false'

runs:
using: node20
Expand Down
6 changes: 5 additions & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const input = {
workingDirectory: core.getInput('working-directory'),
shell: core.getInput('shell'),
postShell: core.getInput('post-shell'),
disableCommandTrace: core.getBooleanInput('disable-command-trace'),
}

export async function run() {
Expand Down Expand Up @@ -62,7 +63,10 @@ async function runCommands(commands, shell) {
return (async () => {
for (const command of commands) {
if (command && command.trim() !== '') {
core.info(`\x1b[1m$ ${command}\x1b[0m`)
// make this behavior default in the next major version
if (!input.disableCommandTrace) {
core.info(`\x1b[1m$ ${command}\x1b[0m`)
}

const exitCode = shell === ''
? await exec.exec(command, [], options)
Expand Down

0 comments on commit e8fbf33

Please sign in to comment.