Skip to content

Commit 7d886a5

Browse files
committed
工作流
1 parent 6fc50bd commit 7d886a5

1 file changed

Lines changed: 30 additions & 39 deletions

File tree

.github/workflows/android-aar.yml

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -76,55 +76,46 @@ jobs:
7676
VERSION=${{ github.event.release.tag_name }}
7777
OWNER=${{ github.repository_owner }}
7878
REPO=${{ github.event.repository.name }}
79-
79+
8080
echo "Triggering build for: com.github.$OWNER/$REPO@$VERSION"
81-
81+
8282
# JitPack API endpoint
8383
API_URL="https://jitpack.io/api/builds/com.github.$OWNER/$REPO/$VERSION"
84+
85+
# Fixed 6 attempts with 10-second intervals
86+
ATTEMPTS=6
87+
RETRY_INTERVAL=30
88+
89+
for ((ATTEMPT=1; ATTEMPT<=ATTEMPTS; ATTEMPT++)); do
90+
echo "Making API call $ATTEMPT of $ATTEMPTS"
8491
85-
# Make initial build request
86-
echo "Making initial build request"
87-
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
88-
-H "Authorization: Bearer $JITPACK_TOKEN" \
89-
"$API_URL")
90-
91-
# Extract HTTP status and response body
92-
HTTP_STATUS=$(echo "$RESPONSE" | grep HTTP_STATUS: | cut -d':' -f2)
93-
BODY=$(echo "$RESPONSE" | sed '/HTTP_STATUS:/d')
94-
95-
echo "Initial API Response: $BODY"
96-
echo "HTTP Status: $HTTP_STATUS"
97-
98-
if [[ "$HTTP_STATUS" != "200" ]]; then
99-
echo "❌ Failed to trigger build (HTTP $HTTP_STATUS)"
100-
exit 1
101-
fi
102-
103-
# Check build status periodically
104-
while true; do
105-
echo "Checking build status..."
106-
STATUS_RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
92+
# Make authenticated request
93+
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
10794
-H "Authorization: Bearer $JITPACK_TOKEN" \
10895
"$API_URL")
109-
110-
STATUS_HTTP=$(echo "$STATUS_RESPONSE" | grep HTTP_STATUS: | cut -d':' -f2)
111-
STATUS_BODY=$(echo "$STATUS_RESPONSE" | sed '/HTTP_STATUS:/d')
112-
113-
# Extract status (case insensitive)
114-
STATUS=$(echo "$STATUS_BODY" | grep -i -o '"status":"[^"]*"' | cut -d'"' -f4 | tr '[:upper:]' '[:lower:]')
115-
116-
if [[ "$STATUS" == "ok" ]]; then
117-
echo "✅ Build succeeded!"
118-
exit 0
119-
elif [[ "$STATUS" == "error" ]]; then
120-
echo "❌ Build failed!"
121-
exit 1
96+
97+
# Extract HTTP status and response body
98+
HTTP_STATUS=$(echo "$RESPONSE" | grep HTTP_STATUS: | cut -d':' -f2)
99+
BODY=$(echo "$RESPONSE" | sed '/HTTP_STATUS:/d')
100+
101+
echo "API Response: $BODY"
102+
echo "HTTP Status: $HTTP_STATUS"
103+
104+
if [[ "$HTTP_STATUS" == "200" ]]; then
105+
echo "✅ Attempt $ATTEMPT: Successfully triggered JitPack build!"
122106
else
123-
echo "🔄 Build in progress (status: ${STATUS:-unknown}), waiting 30 seconds..."
124-
sleep 30
107+
echo "⚠️ Attempt $ATTEMPT: Failed with status $HTTP_STATUS"
108+
fi
109+
110+
# Wait before next attempt (except after last one)
111+
if [ $ATTEMPT -lt $ATTEMPTS ]; then
112+
echo "Waiting $RETRY_INTERVAL seconds before next attempt..."
113+
sleep $RETRY_INTERVAL
125114
fi
126115
done
127116
117+
echo "Completed all $ATTEMPTS API calls"
118+
128119
- name: Monitor Build Status
129120
run: |
130121
VERSION=${{ github.event.release.tag_name }}

0 commit comments

Comments
 (0)