Skip to content

Commit

Permalink
[CI] Fix failure due to not finding workflow run on first page (trito…
Browse files Browse the repository at this point in the history
…n-lang#1907)

Co-authored-by: Philippe Tillet <[email protected]>
  • Loading branch information
zahimoud and ptillet authored Jul 6, 2023
1 parent 787cdff commit 2a2cbc3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,19 @@ jobs:
BRANCH_NAME=$(gh api repos/$OWNER_REPO/pulls/$PR_NUMBER --jq '.head.ref')
echo "BRANCH_NAME: $BRANCH_NAME"
WORKFLOW_RUN_ID=$(gh api --method GET repos/$OWNER_REPO/actions/runs | jq --arg branch_name "$BRANCH_NAME" '.workflow_runs[] | select(.head_branch == $branch_name)' | jq '.id' | head -1)
page=1
while true; do
run_id=$(gh api --method GET "repos/$OWNER_REPO/actions/runs?page=$page&per_page=100" | jq --arg branch_name "$BRANCH_NAME" '.workflow_runs[] | select(.head_branch == $branch_name)' | jq '.id' | head -1)
if [ "$run_id" != "" ]; then
echo "First run ID on branch $BRANCH_NAME is: $run_id"
WORKFLOW_RUN_ID=$run_id
break
fi
((page++))
done
echo "WORKFLOW_RUN_ID: $WORKFLOW_RUN_ID"
ARTIFACT_URL=$(gh api repos/$OWNER_REPO/actions/runs/$WORKFLOW_RUN_ID/artifacts | jq --arg artifact_name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $artifact_name).archive_download_url' --raw-output)
echo "ARTIFACT_URL: $ARTIFACT_URL"
Expand Down

0 comments on commit 2a2cbc3

Please sign in to comment.