From e8fbf3353495945b721533d6e79b1115422e5639 Mon Sep 17 00:00:00 2001 From: jetexe Date: Mon, 7 Oct 2024 20:26:24 +0400 Subject: [PATCH] feat: Add disable-command-traces input option --- .github/workflows/tests.yml | 9 +++++++++ README.md | 15 ++++++++------- action.yml | 4 ++++ src/common.js | 6 +++++- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5611347..d82f2e2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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' diff --git a/README.md b/README.md index e7ddc29..898551f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 13246dd..c607595 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/src/common.js b/src/common.js index ba20dd4..bfd0f75 100644 --- a/src/common.js +++ b/src/common.js @@ -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() { @@ -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)