Skip to content

Commit 7f64c38

Browse files
committed
refactor: add check for artifacts url in lib.sh
1 parent 319795c commit 7f64c38

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ci/lib.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ curl() {
5757
# This will contain the artifacts we want.
5858
# https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
5959
get_artifacts_url() {
60-
curl -fsSL 'https://api.github.com/repos/cdr/code-server/actions/workflows/ci.yaml/runs?status=success&event=push' | jq -r ".workflow_runs[] | select(.head_sha == \"$(git rev-parse HEAD)\") | .artifacts_url" | head -n 1
60+
local head_sha
61+
local artifacts_url
62+
head_sha=$(git rev-parse HEAD)
63+
artifacts_url=$(curl -fsSL 'https://api.github.com/repos/cdr/code-server/actions/workflows/ci.yaml/runs?status=success&event=pull_request' | jq -r ".workflow_runs[] | select(.head_sha == \"$head_sha\") | .artifacts_url" | head -n 1)
64+
if [[ -z "$artifacts_url" ]]; then
65+
>&2 echo "ERROR: artifacts_url came back empty"
66+
>&2 echo "Check the get_artifacts_url function"
67+
exit 1
68+
fi
69+
70+
echo "$artifacts_url"
6171
}
6272

6373
# Grabs the artifact's download url.

0 commit comments

Comments
 (0)