-
Notifications
You must be signed in to change notification settings - Fork 384
Fix Github Action / Control Plane Pipeline #626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
8f7c638
1454772
d70b546
0562a28
d17ca4e
1039020
a6fe0a3
ee5c4f4
c334031
5f30098
328f25f
dfc82c4
d63cfb9
95415c1
1442b41
62c6465
fd00379
6f4ef1e
99a6c33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# This script handles the deployment to Control Plane and extracts the Rails URL | ||
# | ||
# | ||
# Required environment variables: | ||
# - APP_NAME: Name of the application to deploy | ||
# - CPLN_ORG: Control Plane organization | ||
|
@@ -11,7 +11,7 @@ | |
# Must be a positive integer | ||
# | ||
# Outputs: | ||
# - ENV APP_URL: URL of the deployed application | ||
# - rails_url: URL of the deployed Rails application | ||
|
||
set -e | ||
|
||
|
@@ -31,34 +31,21 @@ trap 'rm -f "$TEMP_OUTPUT"' EXIT | |
|
||
# Deploy the application | ||
echo "🚀 Deploying to Control Plane (timeout: ${WAIT_TIMEOUT}s)" | ||
if ! timeout "${WAIT_TIMEOUT}" cpflow deploy-image -a "$APP_NAME" --run-release-phase --org "$CPLN_ORG" --verbose 2>&1 | tee "$TEMP_OUTPUT"; then | ||
echo "❌ Deployment failed" | ||
echo "Full output:" | ||
cat "$TEMP_OUTPUT" | ||
exit 1 | ||
fi | ||
|
||
# Extract app URL from deployment output | ||
APP_URL=$(grep -oP 'https://[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1) | ||
if [ -z "$APP_URL" ]; then | ||
echo "❌ Error: Could not find app URL in deployment output" | ||
exit 1 | ||
if timeout "$WAIT_TIMEOUT" cpflow deploy-image -a "$APP_NAME" --run-release-phase --org "$CPLN_ORG" --verbose | tee "$TEMP_OUTPUT"; then | ||
# Extract Rails URL from deployment output | ||
RAILS_URL=$(grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1) | ||
if [ -n "$RAILS_URL" ]; then | ||
echo "rails_url=$RAILS_URL" >> "$GITHUB_OUTPUT" | ||
echo "✅ Deployment successful" | ||
echo "🚀 Rails URL: $RAILS_URL" | ||
else | ||
echo "❌ Failed to extract Rails URL from deployment output" | ||
exit 1 | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ensure Reliable Deployment Command Execution The deployment command is executed within a pipeline: if timeout "$WAIT_TIMEOUT" cpflow deploy-image -a "$APP_NAME" --run-release-phase --org "$CPLN_ORG" --verbose | tee "$TEMP_OUTPUT"; then Without |
||
elif [ $? -eq 124 ]; then | ||
echo "❌ Deployment timed out after $WAIT_TIMEOUT seconds" | ||
exit 1 | ||
else | ||
echo "❌ Deployment to Control Plane failed" | ||
exit 1 | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fi | ||
|
||
# Wait for all workloads to be ready | ||
echo "⏳ Waiting for all workloads to be ready (timeout: ${WAIT_TIMEOUT}s)" | ||
if ! timeout "${WAIT_TIMEOUT}" bash -c "cpflow ps:wait -a \"$APP_NAME\"" 2>&1 | tee -a "$TEMP_OUTPUT"; then | ||
TIMEOUT_EXIT=$? | ||
if [ ${TIMEOUT_EXIT} -eq 124 ]; then | ||
echo "❌ Timed out waiting for workloads after ${WAIT_TIMEOUT} seconds" | ||
else | ||
echo "❌ Workloads did not become ready" | ||
fi | ||
echo "Full output:" | ||
cat "$TEMP_OUTPUT" | ||
exit 1 | ||
fi | ||
|
||
echo "✅ Deployment successful" | ||
echo "🌐 App URL: $APP_URL" | ||
echo "APP_URL=$APP_URL" >> "$GITHUB_OUTPUT" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ runs: | |
run: | | ||
sudo npm install -g @controlplane/[email protected] | ||
cpln --version | ||
gem install cpflow -v 4.1.0 | ||
gem install cpflow -v 4.1.1 | ||
cpflow --version | ||
|
||
- name: Setup Control Plane Profile | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ permissions: | |
issues: write | ||
|
||
env: | ||
PREFIX: ${{ vars.REVIEW_APP_PREFIX }} | ||
CPLN_ORG: ${{ vars.CPLN_ORG_STAGING }} | ||
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }} | ||
APP_NAME: ${{ vars.REVIEW_APP_PREFIX }}-pr-${{ github.event.pull_request.number || github.event.issue.number || inputs.pr_number }} | ||
|
@@ -43,7 +44,28 @@ jobs: | |
- uses: actions/checkout@v4 | ||
|
||
- name: Validate Required Secrets and Variables | ||
uses: ./.github/actions/validate-required-vars | ||
shell: bash | ||
run: | | ||
missing=() | ||
|
||
# Check required secrets | ||
if [ -z "$CPLN_TOKEN" ]; then | ||
missing+=("Secret: CPLN_TOKEN_STAGING") | ||
fi | ||
|
||
# Check required variables | ||
if [ -z "$CPLN_ORG" ]; then | ||
missing+=("Variable: CPLN_ORG_STAGING") | ||
fi | ||
|
||
if [ -z "$"PREFIX" }} ]; then | ||
missing+=("Variable: REVIEW_APP_PREFIX") | ||
fi | ||
|
||
if [ ${#missing[@]} -ne 0 ]; then | ||
echo "Required secrets/variables are not set: ${missing[*]}" | ||
exit 1 | ||
fi | ||
|
||
Comment on lines
46
to
69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validation Script: Critical Syntax Issue in Variable Check.
is syntactically incorrect. Please change it to:
to correctly validate if 🧰 Tools🪛 YAMLlint (1.35.1)[error] 50-50: trailing spaces (trailing-spaces) [error] 55-55: trailing spaces (trailing-spaces) [error] 64-64: trailing spaces (trailing-spaces) [error] 68-68: trailing spaces (trailing-spaces) |
||
- name: Setup Environment | ||
uses: ./.github/actions/setup-environment | ||
|
Uh oh!
There was an error while loading. Please reload this page.