Skip to content

Commit

Permalink
Workaround issue in GitHub actions REST API (#2811)
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <[email protected]>
Co-authored-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan-Jowett and Alan Jowett authored Sep 1, 2023
1 parent a2210bd commit f47df31
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/Fetch-LatestArtifacts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ if ($null -eq (Get-Command 'gh.exe' -ErrorAction SilentlyContinue)) {

if (!$runid) {
# Get the latest run ID for the branch and workflow
$run = ((Invoke-WebRequest -Uri "https://api.github.com/repos/$Owner/$Repo/actions/runs?per_page=1&exclude_pull_requests=true&branch=$Branch&status=completed&event=schedule&conclusion=success&name=$WorkflowName").Content | ConvertFrom-Json)
$runid = $run.workflow_runs[0].id
# GitHub REST API for Actions: https://docs.github.com/en/rest/reference/actions
# It does not support filtering by workflow name, so we have to get all runs and filter locally.
$run = ((Invoke-WebRequest -Uri "https://api.github.com/repos/$Owner/$Repo/actions/runs?per_page=10&exclude_pull_requests=true&branch=$Branch&status=completed&event=schedule&conclusion=success").Content | ConvertFrom-Json)
$run = $run.workflow_runs | Where-Object { $_.name -eq $WorkflowName } | Select-Object -First 1
$runid = $run.id
}

Write-Output "Using run ID $runid in branch $Branch in repo $Owner/$Repo to fetch artifact $ArtifactName to $OutputPath."
Expand Down

0 comments on commit f47df31

Please sign in to comment.