Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add disable-command-trace option #41

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion dist/main/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/post/index.js

Large diffs are not rendered by default.

8 changes: 7 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,12 @@ async function runCommands(commands, shell) {
return (async () => {
for (const command of commands) {
if (command && command.trim() !== '') {
core.info(`\x1b[1m$ ${command}\x1b[0m`)
core.debug(`input: ${JSON.stringify(input)}`)

// 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