@@ -7,7 +7,7 @@ METRICS_ARTIFACTS_BRANCH=${2:-main}
77
88# env vars
99REPOSITORY_NAME=${REPOSITORY_NAME:- localstack-pro}
10- ARTIFACT_ID=${ARTIFACT_ID:- implemented_features_python-amd64.csv }
10+ ARTIFACT_ID=${ARTIFACT_ID:- implemented_features_python-amd64}
1111WORKFLOW=${WORKFLOW:- " Az / Build, Test, Push" }
1212PREFIX_ARTIFACT=${PREFIX_ARTIFACT:- }
1313FILTER_SUCCESS=${FILTER_SUCCESS:- 1}
3030 SELECTOR=' .[] | select(.status=="completed" and (.conclusion=="failure" or .conclusion=="success"))'
3131fi
3232
33- RUN_IDS=$( gh run list --limit " $LIMIT " --branch " $METRICS_ARTIFACTS_BRANCH " --repo " $REPOSITORY_OWNER /$REPOSITORY_NAME " --workflow " $WORKFLOW " --json databaseId,conclusion,status --jq " $SELECTOR " )
33+ RUN_IDS=()
34+ while IFS= read -r run_id; do
35+ RUN_IDS+=(" $run_id " )
36+ done < <(
37+ gh run list \
38+ --limit " $LIMIT " \
39+ --branch " $METRICS_ARTIFACTS_BRANCH " \
40+ --repo " $REPOSITORY_OWNER /$REPOSITORY_NAME " \
41+ --workflow " $WORKFLOW " \
42+ --json databaseId,conclusion,status \
43+ --jq " $SELECTOR | .databaseId"
44+ )
3445
35- if [ " $( echo " $ RUN_IDS" | jq -rs ' .[0].databaseId ' ) " = " null " ]; then
36- echo " No matching workflow run found."
46+ if [ " ${ # RUN_IDS[@]} " -eq 0 ]; then
47+ echo " No matching workflow runs found."
3748 exit 1
3849fi
3950
40- for (( i= 0 ; i< LIMIT; i++ )) ; do
41- RUN_ID=$( echo " $RUN_IDS " | jq -rs " .[$i ].databaseId" )
51+ for RUN_ID in " ${RUN_IDS[@]} " ; do
52+ if [ -z " $RUN_ID " ] || [ " $RUN_ID " = " null" ]; then
53+ continue
54+ fi
4255 echo " Trying run id: $RUN_ID "
4356
4457 gh run download " $RUN_ID " --repo " $REPOSITORY_OWNER /$REPOSITORY_NAME " -p " $ARTIFACT_ID " -D " $TMP_FOLDER " || true
@@ -49,6 +62,11 @@ for ((i=0; i<LIMIT; i++)); do
4962 fi
5063done
5164
65+ if [ " $( ls -1 " $TMP_FOLDER " 2> /dev/null | wc -l) " -eq 0 ]; then
66+ echo " Failed to download artifact '$ARTIFACT_ID ' from the checked workflow runs."
67+ exit 1
68+ fi
69+
5270echo " Moving artifact to $TARGET_FOLDER "
5371mkdir -p " $TARGET_FOLDER "
5472if [[ -z " ${PREFIX_ARTIFACT} " ]]; then
0 commit comments