Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86ac137

Browse files
authored
docs: add "exec" usage examples
1 parent 378a50f commit 86ac137

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,3 +494,45 @@ jobs:
494494
labels: ['Triage']
495495
})
496496
```
497+
498+
### Using exec package
499+
500+
The provided [@actions/exec](https://github.com/actions/toolkit/tree/main/packages/exec) package allows to execute command or tools in a cross platform way:
501+
502+
```yaml
503+
on: push
504+
505+
jobs:
506+
use-exec:
507+
runs-on: ubuntu-latest
508+
steps:
509+
- uses: actions/checkout@v4
510+
- uses: actions/github-script@v7
511+
with:
512+
script: |
513+
const exitCode = await exec.exec('echo', ['hello'])
514+
515+
console.log(exitCode)
516+
```
517+
518+
`exec` packages provides `getExecOutput` function to retrieve stdout and stderr from executed command:
519+
520+
```yaml
521+
on: push
522+
523+
jobs:
524+
use-get-exec-output:
525+
runs-on: ubuntu-latest
526+
steps:
527+
- uses: actions/checkout@v4
528+
- uses: actions/github-script@v7
529+
with:
530+
script: |
531+
const {
532+
exitCode,
533+
stdout,
534+
stderr
535+
} = await exec.getExecOutput('echo', ['hello']);
536+
537+
console.log(exitCode, stdout, stderr)
538+
```

0 commit comments

Comments
 (0)