Skip to content

Commit 3c7d736

Browse files
Update eas-android-build.yml
1 parent 90617af commit 3c7d736

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

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

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ jobs:
4242
echo "Starting EAS build..."
4343
sudo apt-get install -y jq
4444
45-
# Run build and capture JSON output
4645
BUILD_JSON=$(npx eas build -p android --profile production --non-interactive --json)
4746
echo "Raw build output: $BUILD_JSON"
4847
49-
# Extract BUILD_ID
5048
BUILD_ID=$(echo "$BUILD_JSON" | jq -r '.[0].id')
5149
if [[ -z "$BUILD_ID" || "$BUILD_ID" == "null" ]]; then
5250
echo "Error: Failed to retrieve BUILD_ID!"
@@ -66,10 +64,8 @@ jobs:
6664
outputs:
6765
apk_path: ${{ steps.download.outputs.APK_PATH }}
6866
steps:
69-
- name: Setup Node.js
70-
uses: actions/setup-node@v4
71-
with:
72-
node-version: 20.x
67+
- name: Checkout repository
68+
uses: actions/checkout@v4
7369

7470
- name: Install Required Tools
7571
run: |
@@ -79,30 +75,27 @@ jobs:
7975
8076
- name: Wait for EAS Build to Complete
8177
run: |
78+
cd $GITHUB_WORKSPACE
8279
BUILD_ID=${{ needs.build-android.outputs.build_id }}
8380
echo "Starting build monitoring for BUILD_ID: $BUILD_ID"
84-
npx eas build:view --json $BUILD_ID
8581
8682
RETRY_COUNT=0
87-
MAX_RETRIES=120 # 120 attempts * 30 seconds = 60 minutes
83+
MAX_RETRIES=120
8884
SLEEP_TIME=30
8985
9086
while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do
9187
echo -e "\n=== Attempt $((RETRY_COUNT+1))/$MAX_RETRIES ==="
9288
93-
# Get build status with full error visibility
94-
echo "Fetching build status..."
95-
npx eas build:view --json $BUILD_ID
96-
BUILD_STATUS_JSON=$(npx eas build:view --json $BUILD_ID)
89+
BUILD_STATUS_JSON=$(npx eas build:view --json $BUILD_ID 2>/dev/null)
9790
echo "Raw API response: $BUILD_STATUS_JSON"
9891
99-
# Validate JSON structure
100-
if ! echo "$BUILD_STATUS_JSON" | jq empty >/dev/null 2>&1; then
101-
echo "Error: Invalid JSON response from EAS API!"
102-
exit 1
92+
if [[ -z "$BUILD_STATUS_JSON" || "$BUILD_STATUS_JSON" == "null" ]]; then
93+
echo "Error: Invalid response from EAS API! Retrying..."
94+
RETRY_COUNT=$((RETRY_COUNT+1))
95+
sleep $SLEEP_TIME
96+
continue
10397
fi
10498
105-
# Parse status fields
10699
BUILD_STATUS=$(echo "$BUILD_STATUS_JSON" | jq -r '.status')
107100
ERROR_MESSAGE=$(echo "$BUILD_STATUS_JSON" | jq -r '.error.message // empty')
108101
@@ -113,33 +106,25 @@ jobs:
113106
"finished")
114107
APK_URL=$(echo "$BUILD_STATUS_JSON" | jq -r '.artifacts.buildUrl')
115108
if [[ -z "$APK_URL" || "$APK_URL" == "null" ]]; then
116-
echo "Error: Successful build but no APK URL found!"
117-
echo "Full response: $BUILD_STATUS_JSON"
109+
echo "Error: Build finished but APK URL is missing!"
118110
exit 1
119111
fi
120112
echo "APK_URL=$APK_URL" >> $GITHUB_ENV
121-
echo "Build completed successfully!"
122113
exit 0
123114
;;
124115
125-
"errored")
116+
"errored"|"canceled")
126117
echo "Build failed! Error details:"
127118
echo "$BUILD_STATUS_JSON" | jq .
128119
exit 1
129120
;;
130121
131-
"canceled")
132-
echo "Build was canceled!"
133-
exit 1
134-
;;
135-
136122
"new"|"in_queue"|"in_progress"|"pending")
137-
echo "Build still in progress..."
123+
echo "Build is still in progress..."
138124
;;
139125
140126
*)
141127
echo "Unknown build status: $BUILD_STATUS"
142-
echo "Full response: $BUILD_STATUS_JSON"
143128
exit 1
144129
;;
145130
esac
@@ -149,7 +134,7 @@ jobs:
149134
sleep $SLEEP_TIME
150135
done
151136
152-
echo "Error: Build did not complete within $((MAX_RETRIES * SLEEP_TIME / 60)) minutes!"
137+
echo "Error: Build did not complete within the expected time!"
153138
exit 1
154139
env:
155140
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
@@ -158,7 +143,7 @@ jobs:
158143
id: download
159144
run: |
160145
echo "Downloading APK from: $APK_URL"
161-
curl -L -o app-release.apk "$APK_URL"
146+
curl -L "$APK_URL" -o app-release.apk
162147
ls -lh app-release.apk
163148
echo "APK_PATH=app-release.apk" >> $GITHUB_OUTPUT
164149
@@ -218,4 +203,4 @@ jobs:
218203
body_path: changelog.txt
219204
draft: false
220205
prerelease: false
221-
files: app-release.apk
206+
files: app-release.apk

0 commit comments

Comments
 (0)