Test local collect #64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Download Artifacts from MetricsHub | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
download-artifacts: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout this repository | |
uses: actions/checkout@v4 | |
- name: Download artifacts from MetricsHub | |
shell: pwsh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Define variables | |
$OWNER = "MohammedSentry" | |
$REPO = "metricshub" | |
$BRANCH = "main" | |
# Debug - Print variables | |
Write-Host "Owner: $OWNER" | |
Write-Host "Repo: $REPO" | |
Write-Host "Branch: $BRANCH" | |
# Get the latest successful workflow run ID | |
$workflow_runs = Invoke-RestMethod -Headers @{ Authorization = "Bearer $env:GITHUB_TOKEN" } -Uri "https://api.github.com/repos/$OWNER/$REPO/actions/runs?branch=$BRANCH&status=completed&per_page=5" | |
Write-Host "Workflow runs: $($workflow_runs | ConvertTo-Json -Depth 3)" | |
$run_id = ($workflow_runs.workflow_runs | Where-Object { $_.conclusion -eq "success" })[0].id | |
# Debug - Print run_id | |
Write-Host "Run ID: $run_id" | |
# Get the artifact download URL | |
$artifacts_url = "https://api.github.com/repos/$OWNER/$REPO/actions/runs/$run_id/artifacts" | |
$artifacts = Invoke-RestMethod -Headers @{ Authorization = "Bearer $env:GITHUB_TOKEN" } -Uri $artifacts_url | |
# Debug - Print artifacts | |
Write-Host "Artifacts: $($artifacts | ConvertTo-Json -Depth 3)" | |
# Extract artifact information | |
$artifact = $artifacts.artifacts | Where-Object { $_.name -like "metricshub-windows*" } | Select-Object -First 1 | |
if (-not $artifact) { | |
Write-Error "No artifact found with name starting with 'metricshub-windows'" | |
exit 1 | |
} | |
$artifact_id = $artifact.id | |
$download_url = "https://api.github.com/repos/$OWNER/$REPO/actions/artifacts/$artifact_id/zip" | |
# Debug - Print download URL | |
Write-Host "Download URL: $download_url" | |
# Download the artifact | |
Invoke-WebRequest -Headers @{ Authorization = "Bearer $env:GITHUB_TOKEN" } -Uri $download_url -OutFile artifact.zip | |
# Unzip the artifact | |
mkdir artifacts | |
Expand-Archive artifact.zip -DestinationPath artifacts | |
Expand-Archive artifacts\metricshub-windows*.zip -DestinationPath artifacts | |
- name: List extracted files | |
shell: pwsh | |
run: Get-ChildItem -Path artifacts -Recurse | |
- name: MetricsHub version | |
shell: pwsh | |
run: | | |
Write-Host "Contents of artifacts directory:" | |
Write-Host "Attempting to find and run metricshub.exe" | |
# Find metricshub.exe and run it | |
$exe_path = Get-ChildItem -Path artifacts -Recurse -Filter metricshub.exe | Select-Object -First 1 | |
Write-Host "Found metricshub.exe at $($exe_path.FullName)" | |
& $exe_path.FullName --version | |
- name: MetricsHub localhost collect | |
shell: pwsh | |
run: | | |
Write-Host "Metrics for localhost:" | |
# Find metricshub.exe and run it | |
$exe_path = Get-ChildItem -Path artifacts -Recurse -Filter metricshub.exe | Select-Object -First 1 | |
Write-Host "Found metricshub.exe at $($exe_path.FullName)" | |
& $exe_path.FullName localhost -t win --wmi --connectors Windows | |
- name: List downloaded files | |
shell: pwsh | |
run: Get-ChildItem -Path artifacts |