Skip to content

Commit c6f3f92

Browse files
Restored working build monitoring job/step.
1 parent 3324fe6 commit c6f3f92

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

.github/workflows/eas-android-build.yml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,73 @@ jobs:
144144
- name: "⏳ Wait for Build Completion"
145145
run: |
146146
echo "⏰ Monitoring build status..."
147-
npx eas build:wait --build-id ${{ needs.build-android.outputs.build_id }} --timeout 1800
147+
cd $GITHUB_WORKSPACE
148+
BUILD_ID=${{ needs.build-android.outputs.build_id }}
149+
echo "🔍 Starting build monitoring for BUILD_ID: $BUILD_ID"
150+
151+
# Initial check without JSON for better error visibility
152+
npx eas build:view $BUILD_ID || true
153+
154+
RETRY_COUNT=0
155+
MAX_RETRIES=120
156+
SLEEP_TIME=30
157+
158+
while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do
159+
echo -e "\n=== Attempt $((RETRY_COUNT+1))/$MAX_RETRIES ==="
160+
161+
# Fetch build status in JSON format
162+
BUILD_STATUS_JSON=$(npx eas build:view --json $BUILD_ID)
163+
echo "📄 Raw API response: $BUILD_STATUS_JSON"
164+
165+
# Validate JSON and check for empty response
166+
if ! echo "$BUILD_STATUS_JSON" | jq empty >/dev/null 2>&1 || [[ -z "$BUILD_STATUS_JSON" ]]; then
167+
echo "❌ Error: Invalid or empty response from EAS API! Retrying..."
168+
RETRY_COUNT=$((RETRY_COUNT+1))
169+
sleep $SLEEP_TIME
170+
continue
171+
fi
172+
173+
BUILD_STATUS=$(echo "$BUILD_STATUS_JSON" | jq -r '.status')
174+
ERROR_MESSAGE=$(echo "$BUILD_STATUS_JSON" | jq -r '.error.message // empty')
175+
176+
echo "🔍 Parsed status: $BUILD_STATUS"
177+
[[ -n "$ERROR_MESSAGE" ]] && echo "❌ Error message: $ERROR_MESSAGE"
178+
179+
case $BUILD_STATUS in
180+
"FINISHED")
181+
APK_URL=$(echo "$BUILD_STATUS_JSON" | jq -r '.artifacts.buildUrl')
182+
if [[ -z "$APK_URL" || "$APK_URL" == "null" ]]; then
183+
echo "❌ Error: Successful build but no APK URL found!"
184+
exit 1
185+
fi
186+
echo "✅ APK_URL=$APK_URL" >> $GITHUB_ENV
187+
exit 0
188+
;;
189+
190+
"ERRORED"|"CANCELLED")
191+
echo "❌ Build failed! Error details:"
192+
echo "$BUILD_STATUS_JSON" | jq .
193+
exit 1
194+
;;
195+
196+
"NEW"|"IN_QUE"|"IN_PROGRESS"|"PENDING")
197+
echo "⏳ Build is still in progress..."
198+
;;
199+
200+
*)
201+
echo "❌ Unknown build status: $BUILD_STATUS"
202+
exit 1
203+
;;
204+
esac
205+
206+
RETRY_COUNT=$((RETRY_COUNT+1))
207+
sleep $SLEEP_TIME
208+
done
209+
210+
echo "❌ Error: Build did not complete within the expected time!"
211+
exit 1
212+
env:
213+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
148214

149215
# ========================
150216
# 📦 Artifact Handling

0 commit comments

Comments
 (0)