gh fall back (#7695)

Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
Douwe Osinga 2026-03-06 11:21:30 -05:00 committed by GitHub
parent b4546f62d9
commit a45610ec3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,8 +34,21 @@ if [[ -z "$DOWNLOAD_URL" ]]; then
fi
echo "Downloading $DOWNLOAD_URL"
# Download and extract (nightly.link double-zips)
curl -sL -o "$TMPDIR/goose.zip" "$DOWNLOAD_URL"
# Download artifact — try nightly.link first, fall back to gh CLI
if ! curl -fSL --connect-timeout 10 -o "$TMPDIR/goose.zip" "$DOWNLOAD_URL" 2>/dev/null; then
echo "nightly.link unavailable, falling back to GitHub API..."
RUN_ID=$(echo "$DOWNLOAD_URL" | grep -oE 'actions/runs/[0-9]+' | cut -d/ -f3)
ARTIFACT_NAME=$(echo "$DOWNLOAD_URL" | sed 's/\.zip$//' | xargs basename)
ARTIFACT_ID=$(gh api "repos/$REPO/actions/runs/$RUN_ID/artifacts" \
--jq ".artifacts[] | select(.name==\"$ARTIFACT_NAME\") | .id")
if [[ -z "$ARTIFACT_ID" ]]; then
echo "Could not find artifact '$ARTIFACT_NAME' for run $RUN_ID"
exit 1
fi
gh api "repos/$REPO/actions/artifacts/$ARTIFACT_ID/zip" > "$TMPDIR/goose.zip"
fi
echo "Done."
unzip -o -q "$TMPDIR/goose.zip" -d "$TMPDIR/extracted"
INNER_ZIP=$(find "$TMPDIR/extracted" -name "*.zip" | head -1)
@ -43,6 +56,8 @@ if [[ -n "$INNER_ZIP" ]]; then
unzip -o -q "$INNER_ZIP" -d "$TMPDIR/extracted"
fi
echo "unzipped"
APP=$(find "$TMPDIR/extracted" -name "*.app" -maxdepth 2 | head -1)
if [[ -z "$APP" ]]; then
echo "No .app found in archive."