Skip to content

Commit 34603d8

Browse files
committed
wip
1 parent c90b70b commit 34603d8

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

.github/actions/deploy-to-control-plane/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ runs:
3737
GITHUB_TOKEN: ${{ inputs.github_token }}
3838
PR_NUMBER: ${{ env.PR_NUMBER }}
3939

40+
- name: Setup Control Plane App If It Doesn't Exist
41+
shell: bash
42+
run: |
43+
if ! cpflow exists -a ${{ inputs.app_name }} ; then
44+
echo " Setting up new Control Plane app for app ${{ inputs.app_name }}..."
45+
cpflow setup-app -a ${{ inputs.app_name }}
46+
fi
47+
4048
- name: Deploy to Control Plane
4149
id: deploy
4250
shell: bash

.github/actions/deploy-to-control-plane/scripts/deploy.sh

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# This script handles the deployment to Control Plane and extracts the Rails URL
4-
#
4+
#
55
# Required environment variables:
66
# - APP_NAME: Name of the application to deploy
77
# - CPLN_ORG: Control Plane organization
@@ -31,21 +31,33 @@ trap 'rm -f "$TEMP_OUTPUT"' EXIT
3131

3232
# Deploy the application
3333
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
5145
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

Comments
 (0)