Skip to content

Commit 65c64d1

Browse files
committed
fixes
1 parent c46f595 commit 65c64d1

File tree

2 files changed

+64
-11
lines changed

2 files changed

+64
-11
lines changed

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
github_token:
1414
description: 'GitHub token'
1515
required: true
16+
wait_timeout:
17+
description: 'Timeout in seconds for waiting for workloads to be ready'
18+
required: false
19+
default: 600
1620

1721
outputs:
1822
rails_url:
@@ -39,23 +43,28 @@ runs:
3943
run: |
4044
echo "🚀 Deploying app for PR #$PR_NUMBER..."
4145
42-
# Deploy the application using the already-built image
43-
if ! cpflow deploy-image -a ${{ inputs.app_name }} --run-release-phase --org ${{ inputs.org }}; then
46+
# Deploy the application and capture the Rails URL
47+
if ! DEPLOY_OUTPUT=$(cpflow deploy-image -a ${{ inputs.app_name }} --run-release-phase --org ${{ inputs.org }}); then
4448
echo "❌ Deployment failed for PR #$PR_NUMBER"
4549
exit 1
4650
fi
4751
48-
# Wait for the deployment to be ready
49-
echo "⏳ Waiting for deployment to be ready..."
50-
if ! cpflow wait-ready -a ${{ inputs.app_name }} --org=${{ inputs.org }} --timeout=300; then
51-
echo "❌ Deployment did not become ready for PR #$PR_NUMBER"
52+
# Extract Rails URL from deployment output
53+
RAILS_URL=$(echo "$DEPLOY_OUTPUT" | grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' | head -n1)
54+
if [ -z "$RAILS_URL" ]; then
55+
echo "❌ Failed to get Rails URL from deployment output"
5256
exit 1
5357
fi
5458
55-
# Get the Rails URL
56-
RAILS_URL=$(cpflow get-url -a ${{ inputs.app_name }} --org=${{ inputs.org }})
57-
if [ -z "$RAILS_URL" ]; then
58-
echo "❌ Failed to get Rails URL for PR #$PR_NUMBER"
59+
# Wait for all workloads to be ready
60+
WAIT_TIMEOUT=${WAIT_TIMEOUT:-${inputs.wait_timeout}}
61+
echo "⏳ Waiting for all workloads to be ready (timeout: ${WAIT_TIMEOUT}s)..."
62+
if ! timeout $WAIT_TIMEOUT cpflow ps:wait -a ${{ inputs.app_name }}; then
63+
if [ $? -eq 124 ]; then
64+
echo "❌ Timed out waiting for workloads after ${WAIT_TIMEOUT} seconds"
65+
else
66+
echo "❌ Workloads did not become ready for PR #$PR_NUMBER"
67+
fi
5968
exit 1
6069
fi
6170

.github/workflows/deploy-to-control-plane.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,27 @@ jobs:
163163
FULL_COMMIT="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || steps.getRef.outputs.PR_SHA || github.sha }}"
164164
echo "COMMIT_HASH=${FULL_COMMIT:0:7}" >> $GITHUB_ENV
165165
166+
- name: Update Status - Building
167+
if: steps.determine_action.outputs.action == 'deploy'
168+
uses: actions/github-script@v7
169+
with:
170+
script: |
171+
const result = ${{ steps.init-deployment.outputs.result }};
172+
const commentId = result.commentId;
173+
174+
const buildingMessage = [
175+
'🏗️ Building Docker image for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}',
176+
'',
177+
'[View Build Logs](' + result.workflowUrl + ')'
178+
].join('\n');
179+
180+
await github.rest.issues.updateComment({
181+
owner: context.repo.owner,
182+
repo: context.repo.repo,
183+
comment_id: commentId,
184+
body: buildingMessage
185+
});
186+
166187
- name: Build Docker Image
167188
if: steps.determine_action.outputs.action == 'deploy'
168189
uses: ./.github/actions/build-docker-image
@@ -172,6 +193,29 @@ jobs:
172193
commit: ${{ env.COMMIT_HASH }}
173194
PR_NUMBER: ${{ env.PR_NUMBER }}
174195

196+
- name: Update Status - Deploying
197+
if: steps.determine_action.outputs.action == 'deploy'
198+
uses: actions/github-script@v7
199+
with:
200+
script: |
201+
const result = ${{ steps.init-deployment.outputs.result }};
202+
const commentId = result.commentId;
203+
204+
const deployingMessage = [
205+
'🚀 Deploying to Control Plane for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}',
206+
'',
207+
'⏳ Waiting for deployment to be ready...',
208+
'',
209+
'[View Deploy Logs](' + result.workflowUrl + ')'
210+
].join('\n');
211+
212+
await github.rest.issues.updateComment({
213+
owner: context.repo.owner,
214+
repo: context.repo.repo,
215+
comment_id: commentId,
216+
body: deployingMessage
217+
});
218+
175219
- name: Deploy to Control Plane
176220
if: steps.determine_action.outputs.action == 'deploy'
177221
id: deploy
@@ -181,7 +225,7 @@ jobs:
181225
org: ${{ env.CPLN_ORG }}
182226
github_token: ${{ secrets.GITHUB_TOKEN }}
183227

184-
- name: Update Status
228+
- name: Update Status - Deployment Complete
185229
if: steps.determine_action.outputs.action == 'deploy'
186230
uses: actions/github-script@v7
187231
with:

0 commit comments

Comments
 (0)