Skip to content

Commit 515e135

Browse files
Add action tests for default, explicit, and anonymous token modes
1 parent 2d71a44 commit 515e135

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

.github/workflows/Action-Test.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,92 @@ jobs:
109109
}
110110
Write-Host "Prerelease check passed: '$installed' contains a prerelease segment."
111111
}
112+
113+
ActionTestTokenUseCases:
114+
name: 'ubuntu-latest - [Token use cases]'
115+
runs-on: ubuntu-latest
116+
steps:
117+
- name: Checkout repo
118+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
119+
with:
120+
persist-credentials: false
121+
122+
- name: Action-Test (Default token behavior)
123+
uses: ./
124+
with:
125+
Version: latest
126+
127+
- name: Verify default token behavior
128+
shell: pwsh
129+
env:
130+
GITHUB_TOKEN: ${{ github.token }}
131+
run: |
132+
$expected = (
133+
Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest' `
134+
-Headers @{
135+
'Accept' = 'application/vnd.github+json'
136+
'Authorization' = "Bearer $($env:GITHUB_TOKEN)"
137+
'X-GitHub-Api-Version' = '2022-11-28'
138+
}
139+
).tag_name.TrimStart('v')
140+
141+
$installed = ($PSVersionTable.PSVersion).ToString()
142+
Write-Host "Installed: $installed"
143+
Write-Host "Expected : $expected"
144+
145+
if ($installed -ne $expected) {
146+
throw "Default token behavior failed: expected $expected but got $installed"
147+
}
148+
149+
- name: Action-Test (Explicit token input)
150+
uses: ./
151+
with:
152+
Version: latest
153+
Token: ${{ github.token }}
154+
155+
- name: Verify explicit token input behavior
156+
shell: pwsh
157+
env:
158+
GITHUB_TOKEN: ${{ github.token }}
159+
run: |
160+
$expected = (
161+
Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest' `
162+
-Headers @{
163+
'Accept' = 'application/vnd.github+json'
164+
'Authorization' = "Bearer $($env:GITHUB_TOKEN)"
165+
'X-GitHub-Api-Version' = '2022-11-28'
166+
}
167+
).tag_name.TrimStart('v')
168+
169+
$installed = ($PSVersionTable.PSVersion).ToString()
170+
Write-Host "Installed: $installed"
171+
Write-Host "Expected : $expected"
172+
173+
if ($installed -ne $expected) {
174+
throw "Explicit token behavior failed: expected $expected but got $installed"
175+
}
176+
177+
- name: Action-Test (Anonymous mode)
178+
uses: ./
179+
with:
180+
Version: latest
181+
Token: ''
182+
183+
- name: Verify anonymous mode behavior
184+
shell: pwsh
185+
run: |
186+
$expected = (
187+
Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest' `
188+
-Headers @{
189+
'Accept' = 'application/vnd.github+json'
190+
'X-GitHub-Api-Version' = '2022-11-28'
191+
}
192+
).tag_name.TrimStart('v')
193+
194+
$installed = ($PSVersionTable.PSVersion).ToString()
195+
Write-Host "Installed: $installed"
196+
Write-Host "Expected : $expected"
197+
198+
if ($installed -ne $expected) {
199+
throw "Anonymous mode failed: expected $expected but got $installed"
200+
}

0 commit comments

Comments
 (0)