|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 | 3 | # This script handles the deployment to Control Plane and extracts the Rails URL
|
4 |
| -# |
| 4 | +# |
5 | 5 | # Required environment variables:
|
6 | 6 | # - APP_NAME: Name of the application to deploy
|
7 | 7 | # - CPLN_ORG: Control Plane organization
|
@@ -31,21 +31,33 @@ trap 'rm -f "$TEMP_OUTPUT"' EXIT
|
31 | 31 |
|
32 | 32 | # Deploy the application
|
33 | 33 | echo "🚀 Deploying to Control Plane (timeout: ${WAIT_TIMEOUT}s)"
|
34 |
| -if timeout "$WAIT_TIMEOUT" cpflow deploy-image -a "$APP_NAME" --run-release-phase --org "$CPLN_ORG" --verbose | tee "$TEMP_OUTPUT"; then |
35 |
| - # Extract Rails URL from deployment output |
36 |
| - RAILS_URL=$(grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1) |
37 |
| - if [ -n "$RAILS_URL" ]; then |
38 |
| - echo "rails_url=$RAILS_URL" >> "$GITHUB_OUTPUT" |
39 |
| - echo "✅ Deployment successful" |
40 |
| - echo "🚀 Rails URL: $RAILS_URL" |
41 |
| - else |
42 |
| - echo "❌ Failed to extract Rails URL from deployment output" |
43 |
| - exit 1 |
44 |
| - fi |
45 |
| -elif [ $? -eq 124 ]; then |
46 |
| - echo "❌ Deployment timed out after $WAIT_TIMEOUT seconds" |
47 |
| - exit 1 |
48 |
| -else |
49 |
| - echo "❌ Deployment to Control Plane failed" |
50 |
| - exit 1 |
| 34 | +if ! timeout "$WAIT_TIMEOUT" cpflow deploy-image -a "$APP_NAME" --run-release-phase --org "$CPLN_ORG" --verbose | tee "$TEMP_OUTPUT"; then |
| 35 | + echo "❌ Deployment failed" |
| 36 | + echo "Error output:" |
| 37 | + exit 1 |
| 38 | +fi |
| 39 | + |
| 40 | +# Extract app URL from deployment output |
| 41 | +RAILS_URL=$(grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1) |
| 42 | +if [ -z "$RAILS_URL" ]; then |
| 43 | + echo "❌ Failed to get app URL from deployment output" |
| 44 | + exit 1 |
51 | 45 | fi
|
| 46 | + |
| 47 | +# Wait for all workloads to be ready |
| 48 | +echo "⏳ Waiting for all workloads to be ready (timeout: ${WAIT_TIMEOUT}s)" |
| 49 | +if ! timeout "${WAIT_TIMEOUT}" bash -c "cpflow ps:wait -a \"$APP_NAME\"" 2>&1 | tee -a "$TEMP_OUTPUT"; then |
| 50 | + TIMEOUT_EXIT=$? |
| 51 | + if [ ${TIMEOUT_EXIT} -eq 124 ]; then |
| 52 | + echo "❌ Timed out waiting for workloads after ${WAIT_TIMEOUT} seconds" |
| 53 | + else |
| 54 | + echo "❌ Workloads did not become ready" |
| 55 | + fi |
| 56 | + echo "Full output:" |
| 57 | + cat "$TEMP_OUTPUT" |
| 58 | + exit 1 |
| 59 | +fi |
| 60 | + |
| 61 | +echo "✅ Deployment successful" |
| 62 | +echo "🌐 Rails URL: $RAILS_URL" |
| 63 | +echo "rails_url=$RAILS_URL" >> "$GITHUB_OUTPUT" |
0 commit comments