Skip to content

Commit c269d85

Browse files
Refactor Action-Test workflow: add GITHUB_TOKEN to environment variables for enhanced security and update API call with authentication headers for improved reliability in version resolution.
1 parent b9fb488 commit c269d85

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.github/linters/.jscpd.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"consoleFull"
55
],
66
"ignore": [
7-
"**/tests/**"
7+
"**/tests/**",
8+
"**/action.yml"
89
],
910
"absolute": true
1011
}

.github/workflows/Action-Test.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636

3737
- name: Verify installed version
3838
shell: pwsh
39+
env:
40+
GITHUB_TOKEN: ${{ github.token }}
3941
run: |
4042
# Requested version that came from the matrix
4143
$requested = '${{ matrix.version }}'
@@ -44,9 +46,14 @@ jobs:
4446
if ([string]::IsNullOrWhiteSpace($requested) -or
4547
$requested.Trim().ToLower() -in @('latest','null')) {
4648
47-
$requested = (Invoke-RestMethod `
48-
-Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest'
49-
).tag_name.TrimStart('v')
49+
$requested = (
50+
Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest' `
51+
-Headers @{
52+
'Accept' = 'application/vnd.github+json'
53+
'Authorization' = "Bearer $($env:GITHUB_TOKEN)"
54+
'X-GitHub-Api-Version' = '2022-11-28'
55+
}
56+
).tag_name.TrimStart('v')
5057
Write-Host "Resolved 'latest' → $requested"
5158
}
5259

0 commit comments

Comments
 (0)