Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 62c3794

Browse filesBrowse files
authored
Merge pull request #546 from neilime/patch-1
docs: add "exec" usage examples
2 parents d0bdaba + ea54302 commit 62c3794
Copy full SHA for 62c3794

File tree

1 file changed

+42
-0
lines changed
Filter options

1 file changed

+42
-0
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+42Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.