Skip to content

Commit 6005b29

Browse files
Update README.md to add outputs section and examples for using script results
1 parent 162f9fb commit 6005b29

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

.github/workflows/Action-Test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ jobs:
5656
uses: ./
5757
id: test
5858
with:
59-
Prerelease: true
6059
Script: |
6160
$cat = Get-GitHubOctocat
6261
$zen = Get-GitHubZen

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ For more information on the available functions and automatic loaded variables,
2020
| `Prerelease` | Allow prerelease versions if available | false | `'false'` |
2121
| `WorkingDirectory` | The working directory where the script will run from | false | `${{ github.workspace }}` |
2222

23+
### Outputs
24+
25+
| Name | Description |
26+
| - | - |
27+
| `result` | The output of the script as a JSON object. To create outputs in `result` use [`Set-GitHubOutput`](https://psmodule.io/GitHub/Functions/Set-GitHubOutput/) |
28+
2329
### Examples
2430

2531
#### Example 1: Run a GitHub PowerShell script
@@ -102,6 +108,31 @@ jobs:
102108
}
103109
```
104110
111+
#### Example 5: Using the outputs from the script
112+
113+
Run a script that uses the GitHub PowerShell module and outputs the result.
114+
115+
```yaml
116+
- name: Run GitHub Script
117+
uses: PSModule/GitHub-Script@v1
118+
id: outputs
119+
with:
120+
Script: |
121+
$cat = Get-GitHubOctocat
122+
$zen = Get-GitHubZen
123+
Set-GitHubOutput -Name 'Octocat' -Value $cat
124+
Set-GitHubOutput -Name 'Zen' -Value $zen
125+
126+
- name: Use outputs
127+
shell: pwsh
128+
env:
129+
result: ${{ steps.test.outputs.result }}
130+
run: |
131+
$result = $env:result | ConvertFrom-Json
132+
Set-GitHubStepSummary -Summary $result.WISECAT
133+
Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen'
134+
```
135+
105136
## Related projects
106137
107138
- [actions/create-github-app-token](https://github.com/actions/create-github-app-token) -> Functionality will be brought into GitHub PowerShell module.

0 commit comments

Comments
 (0)