Progress on gh workflow run
This commit is contained in:
parent
c4cee5a195
commit
20c8c49046
|
|
@ -0,0 +1,3 @@
|
|||
export TARGET_ORG="org"
|
||||
export TARGET_REPO="repo"
|
||||
|
||||
|
|
@ -124,3 +124,39 @@ function print_results() {
|
|||
echo "All tests passed!"
|
||||
fi
|
||||
}
|
||||
|
||||
function run_workflow() {
|
||||
local workflow_file="$1"
|
||||
|
||||
echo "Checking if the workflow file exists"
|
||||
gh workflow view -R "${TARGET_ORG}/${TARGET_REPO}" "${workflow_file}" || return 1
|
||||
|
||||
echo "Getting run count before a new run"
|
||||
local target_run_count=$(($(gh run list -R "${TARGET_ORG}/${TARGET_REPO}" --workflow "${workflow_file}" --limit 1 --jq '. | length') + 1))
|
||||
|
||||
local queue_time=$(date +%FT%TZ)
|
||||
|
||||
echo "Running workflow ${workflow_file}"
|
||||
gh workflow run -R "${TARGET_ORG}/${TARGET_REPO}" "${workflow_file}" --ref main -f arc_name="${SCALE_SET_NAME}" || return 1
|
||||
|
||||
echo "Waiting for run to start"
|
||||
local count=0
|
||||
local run_id=
|
||||
while true; do
|
||||
if [[ "${count}" -ge 12 ]]; then
|
||||
echo "Timeout waiting for run to start"
|
||||
return 1
|
||||
fi
|
||||
|
||||
run_id=$(gh run list -R "${TARGET_ORG}/${TARGET_REPO} --workflow ${workflow_file} --created ">${queue_time}" --json name,databaseId --jq '.[] | select(.name | contains("${SCALE_SET_NAME}"))'")
|
||||
if [ -n "$run_id" ]; then
|
||||
echo "Run found: $run_id"
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
count=$((count+1))
|
||||
done
|
||||
|
||||
echo "Waiting for run to complete"
|
||||
gh run watch "${run_id}" -R "${TARGET_ORG}/${TARGET_REPO}" --exit-status
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue