Skip to content

Commit 585c02d

Browse files
committed
fixes
1 parent 3fe506e commit 585c02d

File tree

4 files changed

+41
-18
lines changed

4 files changed

+41
-18
lines changed

.github/actions/build-docker-image/action.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ inputs:
1111
commit:
1212
description: 'Commit SHA to tag the image with'
1313
required: true
14+
PR_NUMBER:
15+
description: 'PR number'
16+
required: true
1417

1518
runs:
1619
using: "composite"
@@ -19,11 +22,11 @@ runs:
1922
id: build
2023
shell: bash
2124
run: |
22-
echo "🏗️ Building Docker image for commit ${{ inputs.commit }}..."
25+
echo "🏗️ Building Docker image for PR #$PR_NUMBER (commit ${{ inputs.commit }})..."
2326
2427
if cpflow build-image -a ${{ inputs.app_name }} --commit=${{ inputs.commit }} --org=${{ inputs.org }}; then
25-
echo "✅ Docker image build successful for commit ${{ inputs.commit }}"
28+
echo "✅ Docker image build successful for PR #$PR_NUMBER (commit ${{ inputs.commit }})"
2629
else
27-
echo "❌ Docker image build failed for commit ${{ inputs.commit }}"
30+
echo "❌ Docker image build failed for PR #$PR_NUMBER (commit ${{ inputs.commit }})"
2831
exit 1
2932
fi

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

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Control Plane GitHub Action
22

33
name: Deploy to Control Plane
4-
description: 'Deploys the application to Control Plane'
4+
description: 'Deploys an application to Control Plane'
55

66
inputs:
77
app_name:
@@ -36,7 +36,29 @@ runs:
3636
- name: Deploy to Control Plane
3737
id: deploy
3838
shell: bash
39-
run: ${{ github.action_path }}/scripts/deploy.sh
40-
env:
41-
APP_NAME: ${{ inputs.app_name }}
42-
CPLN_ORG: ${{ inputs.org }}
39+
run: |
40+
echo "🚀 Deploying app for PR #$PR_NUMBER..."
41+
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
44+
echo "❌ Deployment failed for PR #$PR_NUMBER"
45+
exit 1
46+
fi
47+
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+
exit 1
53+
fi
54+
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+
exit 1
60+
fi
61+
62+
echo "✅ Deployment successful for PR #$PR_NUMBER"
63+
echo "🌐 Rails URL: $RAILS_URL"
64+
echo "rails_url=$RAILS_URL" >> $GITHUB_OUTPUT

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,13 @@ set -e
1414
# Validate required environment variables
1515
: "${APP_NAME:?APP_NAME environment variable is required}"
1616
: "${CPLN_ORG:?CPLN_ORG environment variable is required}"
17-
: "${GITHUB_SHA:?GITHUB_SHA environment variable is required}"
1817

1918
# Set deployment timeout (15 minutes)
2019
TIMEOUT=900
2120

2221
TEMP_OUTPUT=$(mktemp)
2322
trap 'rm -f "$TEMP_OUTPUT"' EXIT
2423

25-
# Build the Docker image
26-
echo "🏗️ Building Docker image..."
27-
if ! cpflow build-image -a "$APP_NAME" --commit="$GITHUB_SHA" --org="$CPLN_ORG"; then
28-
echo "❌ Docker image build failed"
29-
exit 1
30-
fi
31-
3224
# Deploy the application
3325
echo "🚀 Deploying to Control Plane..."
3426
if timeout "$TIMEOUT" cpflow deploy-image -a "$APP_NAME" --run-release-phase --org "$CPLN_ORG" --verbose | tee "$TEMP_OUTPUT"; then

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,20 @@ jobs:
157157
workflowUrl: getWorkflowUrl(context.runId)
158158
};
159159
160+
- name: Set commit hash
161+
if: steps.determine_action.outputs.action == 'deploy'
162+
run: |
163+
FULL_COMMIT="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || steps.getRef.outputs.PR_SHA || github.sha }}"
164+
echo "COMMIT_HASH=${FULL_COMMIT:0:7}" >> $GITHUB_ENV
165+
160166
- name: Build Docker Image
161167
if: steps.determine_action.outputs.action == 'deploy'
162168
uses: ./.github/actions/build-docker-image
163169
with:
164170
app_name: ${{ env.APP_NAME }}
165171
org: ${{ env.CPLN_ORG }}
166-
# Use the same commit resolution as checkout
167-
commit: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || steps.getRef.outputs.PR_SHA || github.sha }}
172+
commit: ${{ env.COMMIT_HASH }}
173+
PR_NUMBER: ${{ env.PR_NUMBER }}
168174

169175
- name: Deploy to Control Plane
170176
if: steps.determine_action.outputs.action == 'deploy'

0 commit comments

Comments
 (0)