Skip to content

Commit 59b4c49

Browse files
🩹 [Patch]: Update README to include example for using Set-GitHubOutput in workflows
1 parent 6a93c3f commit 59b4c49

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ For more information on the available functions and automatic loaded variables,
2626
| - | - |
2727
| `result` | The output of the script as a JSON object. To add outputs to `result`, use `Set-GitHubOutput`. |
2828

29+
To use the outputs in a subsequent step, you can use the following syntax:
30+
31+
```yaml
32+
- uses: PSModule/GitHub-Script@v1
33+
id: set-output
34+
with:
35+
Script: |
36+
Set-GitHubOutput -Name 'Octocat' -Value @{
37+
Name = 'Octocat'
38+
Image = 'https://octodex.github.com/images/original.png'
39+
}
40+
41+
- name: Use outputs
42+
shell: pwsh
43+
env:
44+
result: ${{ steps.set-output.outputs.result }} # = '{"Octocat":{"Name":"Octocat","Image":"https://octodex.github.com/images/original.png"}}'
45+
name: ${{ fromJson(steps.set-output.outputs.result).Octocat.Name }} # = 'Octocat'
46+
run: |
47+
$result = $env:result | ConvertFrom-Json
48+
Write-Output $env:name
49+
Write-Output $result.Octocat.Image
50+
```
51+
52+
2953
### Examples
3054
3155
#### Example 1: Run a GitHub PowerShell script

0 commit comments

Comments
 (0)