Skip to content

Commit 1a01fda

Browse files
🩹 [Refactor]: Update workflow to download and extract code coverage artifacts
1 parent 53c7c46 commit 1a01fda

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

‎.github/workflows/workflow.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,39 @@ jobs:
194194
- Test-ModuleLocal
195195
steps:
196196
- name: Status
197-
shell: pwsh
198-
run: |
199-
[pscustomobject]@{
200-
TestModule = '${{ needs.Test-Module.result }}'
201-
TestModuleLocal = '${{ needs.Test-ModuleLocal.result }}'
202-
}
197+
uses: PSModule/GitHub-Script@v1
198+
with:
199+
Debug: ${{ inputs.Debug }}
200+
Prerelease: ${{ inputs.Prerelease }}
201+
Verbose: ${{ inputs.Verbose }}
202+
Version: ${{ inputs.Version }}
203+
WorkingDirectory: ${{ inputs.WorkingDirectory }}
204+
Script: |
205+
$repository = $env:GITHUB_REPOSITORY
206+
$runId = $env:GITHUB_RUN_ID
207+
$OutputPath = "./CodeCoverageArtifacts"
208+
New-Item -ItemType Directory -Path $OutputPath | Out-Null
209+
$artifactsJson = gh api "repos/$repository/actions/runs/$runId/artifacts" | ConvertFrom-Json
210+
foreach ($artifact in $artifactsJson.artifacts) {
211+
if ($artifact.name -like "*CodeCoverage") {
212+
$zipPath = Join-Path $OutputPath "$($artifact.name).zip"
213+
214+
Write-Host "Downloading artifact '$($artifact.name)'..."
215+
gh api `
216+
--method GET `
217+
-H "Accept: application/vnd.github+json" `
218+
"/repos/$repository/actions/artifacts/$($artifact.id)/zip" `
219+
--output $zipPath
220+
221+
# Extract the artifact
222+
Write-Host "Extracting artifact '$($artifact.name)'..."
223+
Expand-Archive -Path $zipPath -DestinationPath (Join-Path $OutputPath $artifact.name) -Force
224+
225+
# Optionally remove the zip after extraction
226+
Remove-Item $zipPath -Force
227+
}
228+
}
229+
Get-ChildItem -Path $OutputPath -Recurse
203230
204231
# TestModuleStatus:
205232
# name: Test module status

0 commit comments

Comments
 (0)