Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support downloading artifacts from release builds #667

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions utils/gh-dl-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,22 @@ ixmsg "Locating $arch build of $rev"
sha=$(gh api "$apibase/commits/$rev" -q .sha || die "ERROR: Unknown revision \"$rev\"")
echo "SHA: $sha"

run=$(gh api "$apibase/actions/runs?head_sha=$sha" \
-q '[.workflow_runs[] | select(.name == "Bob the Builder")][0].id' \
|| die "ERROR: Found no workflow runs associated with $rev")
echo "Run: $run"

gh api "$apibase/actions/runs/$run/artifacts" \
-q ".artifacts[] | select(.name == \"artifact-$arch\")" >$workdir/artifact.json \
|| die "ERROR: Found no $arch artifact associated with run $run"
artifact="$(jq .id $workdir/artifact.json)"
runs=$(gh api "$apibase/actions/runs?head_sha=$sha" \
-q '.workflow_runs[] | .id' | tr '\n' ' ' \
|| die "ERROR: Found no workflow runs associated with $rev")

echo "Runs: $runs"

for run in $runs; do
gh api "$apibase/actions/runs/$run/artifacts" \
-q ".artifacts[] | select(.name == \"artifact-$arch\")" >$workdir/artifact.json \
|| continue

artifact="$(jq .id $workdir/artifact.json)"
[ "$artifact" ] && break
done

[ "$artifact" ] || die "ERROR: Found no $arch artifact associated with any of the runs $runs"
echo "Artifact: $artifact"

url="$(jq -r .archive_download_url $workdir/artifact.json)"
Expand Down Expand Up @@ -153,7 +160,7 @@ gh api $url >$zip

ixmsg "Extracting artifact"
mkdir -p $imgdir
unzip -p $zip infix-$arch.tar.gz | gunzip | tar -C $imgdir -x --strip-components=1
unzip -p $zip "infix-${arch}*.tar.gz" | gunzip | tar -C $imgdir -x --strip-components=1


ixmsg "Done"
Expand Down