Skip to content

Commit 49efcc3

Browse files
committed
chore: add error handling for last successful run in ci.yml
1 parent ce1cf85 commit 49efcc3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,21 @@ jobs:
173173
-H "Accept: application/vnd.github+json" \
174174
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
175175
-H "X-GitHub-Api-Version: 2022-11-28" \
176-
https://api.github.com/repos/${{ github.repository }}/actions/runs?status=success&per_page=1 | \
176+
"https://api.github.com/repos/${{ github.repository }}/actions/runs?status=success&per_page=1" | \
177177
jq -r '.workflow_runs[0].id')
178-
178+
179+
echo "LAST_SUCCESSFUL_RUN_ID=$LAST_SUCCESSFUL_RUN_ID" >> $GITHUB_ENV
180+
181+
if [ -z "$LAST_SUCCESSFUL_RUN_ID" ]; then
182+
echo "No successful runs found."
183+
exit 1
184+
fi
185+
179186
ARTIFACT_IDS=$(curl \
180187
-H "Accept: application/vnd.github+json" \
181188
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
182189
-H "X-GitHub-Api-Version: 2022-11-28" \
183-
https://api.github.com/repos/${{ github.repository }}/actions/runs/"${LAST_SUCCESSFUL_RUN_ID}"/artifacts | \
190+
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${LAST_SUCCESSFUL_RUN_ID}/artifacts" | \
184191
jq -r '.artifacts | sort_by(.created_at) | .[] | select(.name | startswith("testresults-")) | .id')
185192
186193
echo "ARTIFACT_IDS=$ARTIFACT_IDS" >> $GITHUB_ENV

0 commit comments

Comments
 (0)