Skip to content

Commit a559abc

Browse files
committed
refactor: change get_artifacts_url in lib.sh
This now looks for the version branch i.e. v3.9.2 to grab the artifacts instead of the head_sha which was faulty in the past.
1 parent f55f79f commit a559abc

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ci/lib.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,20 @@ 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-
local head_sha
6160
local artifacts_url
62-
head_sha=$(git rev-parse HEAD)
63-
artifacts_url=$(curl -fsSL 'https://github.com/api/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)
61+
local code_server_version
62+
local version_branch
63+
local workflow_runs_url
64+
workflow_runs_url="https://github.com/api/repos/cdr/code-server/actions/workflows/ci.yaml/runs?status=success&event=pull_request"
65+
code_server_version=$(node -pe "require('./package.json').version")
66+
# For releases, we look for run based on the branch name v$code_server_version
67+
# example: v3.9.2
68+
version_branch="v$code_server_version"
69+
artifacts_url=$(curl -fsSL "$workflow_runs_url" | jq -r ".workflow_runs[] | select(.head_branch == \"$version_branch\") | .artifacts_url" | head -n 1)
6470
if [[ -z "$artifacts_url" ]]; then
6571
echo >&2 "ERROR: artifacts_url came back empty"
66-
echo >&2 "Check the get_artifacts_url function"
72+
echo >&2 "We looked for a successful run triggered by a pull_request with for code-server version: $code_server_version and a branch named $version_branch"
73+
echo >&2 "URL used for curl call: $workflow_runs_url"
6774
exit 1
6875
fi
6976

0 commit comments

Comments
 (0)