Skip to content

Commit 582d185

Browse files
Refactor Action-Test workflow to enable job definitions and enhance README documentation for input descriptions and examples
1 parent 5b7b7d0 commit 582d185

File tree

3 files changed

+119
-123
lines changed

3 files changed

+119
-123
lines changed

.github/workflows/Action-Test.yml

Lines changed: 106 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,32 @@ permissions:
1717
pull-requests: read
1818

1919
jobs:
20-
# ActionTestBasic:
21-
# name: Action-Test - [Basic]
22-
# runs-on: ubuntu-latest
23-
# steps:
24-
# # Need to check out as part of the test, as its a local action
25-
# - name: Checkout repo
26-
# uses: actions/checkout@v4
27-
28-
# - name: Action-Test
29-
# uses: ./
30-
31-
# ActionTestWithScript:
32-
# name: Action-Test - [WithScript]
33-
# runs-on: ubuntu-latest
34-
# steps:
35-
# # Need to check out as part of the test, as its a local action
36-
# - name: Checkout repo
37-
# uses: actions/checkout@v4
38-
39-
# - name: Action-Test
40-
# uses: ./
41-
# with:
42-
# Script: |
43-
# LogGroup 'Get-GitHubZen' {
44-
# Get-GitHubZen
45-
# }
20+
ActionTestBasic:
21+
name: Action-Test - [Basic]
22+
runs-on: ubuntu-latest
23+
steps:
24+
# Need to check out as part of the test, as its a local action
25+
- name: Checkout repo
26+
uses: actions/checkout@v4
27+
28+
- name: Action-Test
29+
uses: ./
30+
31+
ActionTestWithScript:
32+
name: Action-Test - [WithScript]
33+
runs-on: ubuntu-latest
34+
steps:
35+
# Need to check out as part of the test, as its a local action
36+
- name: Checkout repo
37+
uses: actions/checkout@v4
38+
39+
- name: Action-Test
40+
uses: ./
41+
with:
42+
Script: |
43+
LogGroup 'Get-GitHubZen' {
44+
Get-GitHubZen
45+
}
4646
4747
ActionTestCommands:
4848
name: Action-Test - [Commands]
@@ -73,83 +73,83 @@ jobs:
7373
Set-GitHubStepSummary -Summary $result.WISECAT
7474
Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen'
7575
76-
# ActionTestWithoutToken:
77-
# name: Action-Test - [WithoutToken]
78-
# runs-on: ubuntu-latest
79-
# steps:
80-
# # Need to check out as part of the test, as its a local action
81-
# - name: Checkout repo
82-
# uses: actions/checkout@v4
83-
84-
# - name: Action-Test
85-
# uses: ./
86-
# with:
87-
# Token: ''
88-
# Script: |
89-
# LogGroup 'My group' {
90-
# 'This is a group'
91-
# }
92-
93-
# ActionTestWithPAT:
94-
# name: Action-Test - [WithPAT]
95-
# runs-on: ubuntu-latest
96-
# steps:
97-
# # Need to check out as part of the test, as its a local action
98-
# - name: Checkout repo
99-
# uses: actions/checkout@v4
100-
101-
# - name: Action-Test
102-
# uses: ./
103-
# with:
104-
# Token: ${{ secrets.TEST_PAT }}
105-
# Script: |
106-
# LogGroup 'Get-GitHubUser' {
107-
# Get-GitHubUser | Format-Table -AutoSize
108-
# }
109-
110-
# ActionTestWithFGPAT:
111-
# name: Action-Test - [WithFGPAT]
112-
# runs-on: ubuntu-latest
113-
# steps:
114-
# # Need to check out as part of the test, as its a local action
115-
# - name: Checkout repo
116-
# uses: actions/checkout@v4
117-
118-
# - name: Action-Test
119-
# uses: ./
120-
# with:
121-
# Token: ${{ secrets.TEST_FG_PAT }}
122-
# Script: |
123-
# LogGroup 'Get-GitHubUser' {
124-
# Get-GitHubUser | Format-Table -AutoSize
125-
# }
126-
127-
# ActionTestWithGitHubApp:
128-
# name: Action-Test - [GitHubApp]
129-
# runs-on: ubuntu-latest
130-
# steps:
131-
# # Need to check out as part of the test, as its a local action
132-
# - name: Checkout repo
133-
# uses: actions/checkout@v4
134-
135-
# - name: Action-Test
136-
# uses: ./
137-
# with:
138-
# ClientID: ${{ secrets.TEST_APP_CLIENT_ID }}
139-
# PrivateKey: ${{ secrets.TEST_APP_PRIVATE_KEY }}
140-
# Script: |
141-
# LogGroup 'Get-GitHubApp' {
142-
# Get-GitHubApp | Format-Table -AutoSize
143-
# }
144-
145-
# LogGroup 'Get-GitHubAppInstallation' {
146-
# Get-GitHubAppInstallation | Format-Table -AutoSize
147-
# }
148-
149-
# LogGroup 'Do something as an installation' {
150-
# Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object {
151-
# Connect-GitHub -Token $_.token -Silent
152-
# Get-GitHubContext | Format-Table -AutoSize
153-
# Get-GitHubGitConfig | Format-Table -AutoSize
154-
# }
155-
# }
76+
ActionTestWithoutToken:
77+
name: Action-Test - [WithoutToken]
78+
runs-on: ubuntu-latest
79+
steps:
80+
# Need to check out as part of the test, as its a local action
81+
- name: Checkout repo
82+
uses: actions/checkout@v4
83+
84+
- name: Action-Test
85+
uses: ./
86+
with:
87+
Token: ''
88+
Script: |
89+
LogGroup 'My group' {
90+
'This is a group'
91+
}
92+
93+
ActionTestWithPAT:
94+
name: Action-Test - [WithPAT]
95+
runs-on: ubuntu-latest
96+
steps:
97+
# Need to check out as part of the test, as its a local action
98+
- name: Checkout repo
99+
uses: actions/checkout@v4
100+
101+
- name: Action-Test
102+
uses: ./
103+
with:
104+
Token: ${{ secrets.TEST_PAT }}
105+
Script: |
106+
LogGroup 'Get-GitHubUser' {
107+
Get-GitHubUser | Format-Table -AutoSize
108+
}
109+
110+
ActionTestWithFGPAT:
111+
name: Action-Test - [WithFGPAT]
112+
runs-on: ubuntu-latest
113+
steps:
114+
# Need to check out as part of the test, as its a local action
115+
- name: Checkout repo
116+
uses: actions/checkout@v4
117+
118+
- name: Action-Test
119+
uses: ./
120+
with:
121+
Token: ${{ secrets.TEST_FG_PAT }}
122+
Script: |
123+
LogGroup 'Get-GitHubUser' {
124+
Get-GitHubUser | Format-Table -AutoSize
125+
}
126+
127+
ActionTestWithGitHubApp:
128+
name: Action-Test - [GitHubApp]
129+
runs-on: ubuntu-latest
130+
steps:
131+
# Need to check out as part of the test, as its a local action
132+
- name: Checkout repo
133+
uses: actions/checkout@v4
134+
135+
- name: Action-Test
136+
uses: ./
137+
with:
138+
ClientID: ${{ secrets.TEST_APP_CLIENT_ID }}
139+
PrivateKey: ${{ secrets.TEST_APP_PRIVATE_KEY }}
140+
Script: |
141+
LogGroup 'Get-GitHubApp' {
142+
Get-GitHubApp | Format-Table -AutoSize
143+
}
144+
145+
LogGroup 'Get-GitHubAppInstallation' {
146+
Get-GitHubAppInstallation | Format-Table -AutoSize
147+
}
148+
149+
LogGroup 'Do something as an installation' {
150+
Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object {
151+
Connect-GitHub -Token $_.token -Silent
152+
Get-GitHubContext | Format-Table -AutoSize
153+
Get-GitHubGitConfig | Format-Table -AutoSize
154+
}
155+
}

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,27 @@ For more information on the available functions and automatic loaded variables,
1010

1111
| Name | Description | Required | Default |
1212
| - | - | - | - |
13-
| `Script` | The script to run | false | |
14-
| `Token` | Log in using an Installation Access Token (IAT) | false | `${{ github.token }}` |
15-
| `ClientID` | Log in using a GitHub App, using the App's Client ID and Private Key | false | |
16-
| `PrivateKey` | Log in using a GitHub App, using the App's Client ID and Private Key | false | |
17-
| `Debug` | Enable debug output | false | `'false'` |
18-
| `Verbose` | Enable verbose output | false | `'false'` |
13+
| `Script` | The script to run. Can be inline, multi-line or a path to a script file. | false | |
14+
| `Token` | Log in using an Installation Access Token (IAT). | false | `${{ github.token }}` |
15+
| `ClientID` | Log in using a GitHub App, using the App's Client ID and Private Key. | false | |
16+
| `PrivateKey` | Log in using a GitHub App, using the App's Client ID and Private Key. | false | |
17+
| `Debug` | Enable debug output. | false | `'false'` |
18+
| `Verbose` | Enable verbose output. | false | `'false'` |
1919
| `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | false | |
20-
| `Prerelease` | Allow prerelease versions if available | false | `'false'` |
21-
| `WorkingDirectory` | The working directory where the script will run from | false | `${{ github.workspace }}` |
20+
| `Prerelease` | Allow prerelease versions if available. | false | `'false'` |
21+
| `WorkingDirectory` | The working directory where the script will run from. | false | `${{ github.workspace }}` |
2222

2323
### Outputs
2424

2525
| Name | Description |
2626
| - | - |
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/) |
27+
| `result` | The output of the script as a JSON object. To add outputs to `result`, use `Set-GitHubOutput`. |
2828

2929
### Examples
3030

3131
#### Example 1: Run a GitHub PowerShell script
3232

33-
Run a script that uses the GitHub PowerShell module.
34-
This example runs an authenticated script using the `GITHUB_TOKEN` and gets the GitHub Zen message.
33+
Run a script (`scripts/main.ps1`) that uses the GitHub PowerShell module, authenticated using the `GITHUB_TOKEN`.
3534

3635
```yaml
3736
jobs:
@@ -41,10 +40,7 @@ jobs:
4140
- name: Run script
4241
uses: PSModule/GitHub-Script@v1
4342
with:
44-
Script: |
45-
LogGroup "Get-GitHubZen" {
46-
Get-GitHubZen
47-
}
43+
Script: "scripts/main.ps1"
4844
```
4945
5046
#### Example 2: Run a GitHub PowerShell script without a token

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ branding:
77

88
inputs:
99
Script:
10-
description: The script to run.
10+
description: The script to run. Can be inline, multi-line or a path to a script file.
1111
required: false
1212
Token:
1313
description: Log in using an Installation Access Token (IAT).
@@ -41,7 +41,7 @@ inputs:
4141

4242
outputs:
4343
result:
44-
description: The output of the script.
44+
description: The output of the script as a JSON object. To add outputs to `result`, use `Set-GitHubOutput`.
4545
value: ${{ steps.RunGitGubScript.outputs.result }}
4646

4747
runs:

0 commit comments

Comments
 (0)