Skip to content

Commit d5b8b7f

Browse files
committed
fix-for-delete
1 parent 7d75738 commit d5b8b7f

File tree

4 files changed

+62
-29
lines changed

4 files changed

+62
-29
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ inputs:
1616
wait_timeout:
1717
description: 'Timeout in seconds for waiting for workloads to be ready'
1818
required: false
19-
default: 600
19+
default: '900'
2020

2121
outputs:
2222
review_app_url:
@@ -66,7 +66,11 @@ runs:
6666
6767
# Wait for all workloads to be ready
6868
WAIT_TIMEOUT=${WAIT_TIMEOUT:-${{ inputs.wait_timeout }}}
69-
echo "⏳ Waiting for all workloads to be ready (timeout: ${WAIT_TIMEOUT}s)..."
69+
if ! [[ "${WAIT_TIMEOUT}" =~ ^[0-9]+$ ]]; then
70+
echo "❌ Invalid timeout value: ${WAIT_TIMEOUT}"
71+
exit 1
72+
fi
73+
echo "⏳ Waiting for all workloads to be ready (timeout: ${WAIT_TIMEOUT}s)"
7074
7175
# Use timeout command with ps:wait and show output in real-time
7276
if ! timeout "${WAIT_TIMEOUT}" bash -c "cpflow ps:wait -a \"${{ inputs.app_name }}\"" 2>&1 | tee -a "${TEMP_OUTPUT}"; then

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
# - APP_NAME: Name of the application to deploy
77
# - CPLN_ORG: Control Plane organization
88
#
9+
# Optional environment variables:
10+
# - WAIT_TIMEOUT: Timeout in seconds for deployment (default: 900)
11+
# Must be a positive integer
12+
#
913
# Outputs:
1014
# - rails_url: URL of the deployed Rails application
1115

@@ -15,15 +19,19 @@ set -e
1519
: "${APP_NAME:?APP_NAME environment variable is required}"
1620
: "${CPLN_ORG:?CPLN_ORG environment variable is required}"
1721

18-
# Set deployment timeout (15 minutes)
19-
TIMEOUT=900
22+
# Set and validate deployment timeout
23+
WAIT_TIMEOUT=${WAIT_TIMEOUT:-900}
24+
if ! [[ "${WAIT_TIMEOUT}" =~ ^[0-9]+$ ]]; then
25+
echo "❌ Invalid timeout value: ${WAIT_TIMEOUT}"
26+
exit 1
27+
fi
2028

2129
TEMP_OUTPUT=$(mktemp)
2230
trap 'rm -f "$TEMP_OUTPUT"' EXIT
2331

2432
# Deploy the application
25-
echo "🚀 Deploying to Control Plane..."
26-
if timeout "$TIMEOUT" cpflow deploy-image -a "$APP_NAME" --run-release-phase --org "$CPLN_ORG" --verbose | tee "$TEMP_OUTPUT"; then
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
2735
# Extract Rails URL from deployment output
2836
RAILS_URL=$(grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1)
2937
if [ -n "$RAILS_URL" ]; then
@@ -35,7 +43,7 @@ if timeout "$TIMEOUT" cpflow deploy-image -a "$APP_NAME" --run-release-phase --o
3543
exit 1
3644
fi
3745
elif [ $? -eq 124 ]; then
38-
echo "❌ Deployment timed out after $TIMEOUT seconds"
46+
echo "❌ Deployment timed out after $WAIT_TIMEOUT seconds"
3947
exit 1
4048
else
4149
echo "❌ Deployment to Control Plane failed"

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
done
6161
6262
if [ ${#missing_secrets[@]} -ne 0 ]; then
63-
echo "Required secrets are not set: ${missing_secrets[*]}"
63+
echo "Required secrets are not set: ${missing_secrets[*]}"
6464
exit 1
6565
fi
6666
@@ -74,7 +74,7 @@ jobs:
7474
script: |
7575
core.exportVariable('GET_CONSOLE_LINK', `
7676
function getConsoleLink(prNumber) {
77-
return '🎮 [Control Plane Console for Review App with PR #' + prNumber + '](' +
77+
return ' [Control Plane Console for Review App with PR #' + prNumber + '](' +
7878
'https://console.cpln.io/org/' + process.env.CPLN_ORG + '/workloads/' + process.env.APP_NAME + ')';
7979
}
8080
`);
@@ -110,7 +110,7 @@ jobs:
110110
owner: context.repo.owner,
111111
repo: context.repo.repo,
112112
issue_number: process.env.PR_NUMBER,
113-
body: ' Initializing deployment...'
113+
body: ' Initializing deployment...'
114114
});
115115
116116
// Create GitHub deployment
@@ -148,9 +148,9 @@ jobs:
148148
eval(process.env.GET_CONSOLE_LINK);
149149
150150
const buildingMessage = [
151-
'🏗️ Building Docker image for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}',
151+
' Building Docker image for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}',
152152
'',
153-
'📋 [View Build Logs](' + process.env.WORKFLOW_URL + ')',
153+
' [View Build Logs](' + process.env.WORKFLOW_URL + ')',
154154
'',
155155
getConsoleLink(process.env.PR_NUMBER)
156156
].join('\n');
@@ -177,11 +177,11 @@ jobs:
177177
eval(process.env.GET_CONSOLE_LINK);
178178
179179
const deployingMessage = [
180-
'🚀 Deploying to Control Plane...',
180+
' Deploying to Control Plane...',
181181
'',
182-
' Waiting for deployment to be ready...',
182+
' Waiting for deployment to be ready...',
183183
'',
184-
'📋 [View Deploy Logs](' + process.env.WORKFLOW_URL + ')',
184+
' [View Deploy Logs](' + process.env.WORKFLOW_URL + ')',
185185
'',
186186
getConsoleLink(process.env.PR_NUMBER)
187187
].join('\n');
@@ -199,6 +199,7 @@ jobs:
199199
app_name: ${{ env.APP_NAME }}
200200
org: ${{ env.CPLN_ORG }}
201201
github_token: ${{ secrets.GITHUB_TOKEN }}
202+
wait_timeout: ${{ vars.WAIT_TIMEOUT || 900 }}
202203

203204
- name: Update Status - Deployment Complete
204205
uses: actions/github-script@v7
@@ -226,19 +227,19 @@ jobs:
226227
227228
// Define messages based on deployment status
228229
const successMessage = [
229-
' Deployment complete for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
230+
' Deployment complete for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
230231
'',
231-
'🚀 [Review App for PR #' + prNumber + '](' + appUrl + ')',
232+
' [Review App for PR #' + prNumber + '](' + appUrl + ')',
232233
'',
233-
'📋 [View Completed Action Build and Deploy Logs](' + workflowUrl + ')',
234+
' [View Completed Action Build and Deploy Logs](' + workflowUrl + ')',
234235
'',
235236
getConsoleLink(prNumber)
236237
].join('\n');
237238
238239
const failureMessage = [
239-
' Deployment failed for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
240+
' Deployment failed for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
240241
'',
241-
'📋 [View Deployment Logs with Errors](' + workflowUrl + ')',
242+
' [View Deployment Logs with Errors](' + workflowUrl + ')',
242243
'',
243244
getConsoleLink(prNumber)
244245
].join('\n');
@@ -282,7 +283,7 @@ jobs:
282283
with:
283284
script: |
284285
const helpMessage = [
285-
'## 📚 Available Commands',
286+
'## Available Commands',
286287
'',
287288
'### `/deploy`',
288289
'Deploys your PR branch to a review environment on Control Plane.',
@@ -349,7 +350,7 @@ jobs:
349350
done
350351
351352
if [ ${#missing_secrets[@]} -ne 0 ]; then
352-
echo "Required secrets are not set: ${missing_secrets[*]}"
353+
echo "Required secrets are not set: ${missing_secrets[*]}"
353354
exit 1
354355
fi
355356
@@ -365,7 +366,7 @@ jobs:
365366
issue_number: process.env.PR_NUMBER,
366367
owner: context.repo.owner,
367368
repo: context.repo.repo,
368-
body: '🗑️ Starting app deletion...'
369+
body: ' Starting app deletion...'
369370
});
370371
return { commentId: comment.data.id };
371372
@@ -388,11 +389,11 @@ jobs:
388389
const cpConsoleUrl = `https://console.cpln.io/org/${process.env.CPLN_ORG}/workloads/${process.env.APP_NAME}`;
389390
390391
const message = success
391-
? ' Review app for PR #' + prNumber + ' was successfully deleted'
392+
? ' Review app for PR #' + prNumber + ' was successfully deleted'
392393
: [
393-
' Review app for PR #' + prNumber + ' failed to be deleted',
394+
' Review app for PR #' + prNumber + ' failed to be deleted',
394395
'',
395-
'🎮 [Control Plane Console for Review App with PR #' + prNumber + '](' + cpConsoleUrl + ')'
396+
' [Control Plane Console for Review App with PR #' + prNumber + '](' + cpConsoleUrl + ')'
396397
].join('\n');
397398
398399
await github.rest.issues.updateComment({

.github/workflows/help-command.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
with:
4141
script: |
4242
const helpMessage = [
43-
'## Available Commands',
43+
'## 📚 Available Commands',
4444
'',
4545
'### `/deploy`',
4646
'Deploys your PR branch to a review environment on Control Plane.',
@@ -49,17 +49,37 @@ jobs:
4949
'- Provides a unique URL to preview your changes',
5050
'- Shows build and deployment progress in real-time',
5151
'',
52+
'**Required Environment Variables:**',
53+
'- `CPLN_TOKEN`: Control Plane authentication token',
54+
'- `CPLN_ORG`: Control Plane organization name',
55+
'',
56+
'**Optional Configuration:**',
57+
'- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)',
58+
' - Must be a positive integer',
59+
' - Can be set in GitHub Actions variables',
60+
' - Applies to both deployment and workload readiness checks',
61+
'',
5262
'### `/delete-review-app`',
5363
'Deletes the review app associated with this PR.',
5464
'- Removes all resources from Control Plane',
5565
'- Helpful for cleaning up when you\'re done testing',
5666
'- Can be re-deployed later using `/deploy`',
5767
'',
68+
'**Required Environment Variables:**',
69+
'- `CPLN_TOKEN`: Control Plane authentication token',
70+
'- `CPLN_ORG`: Control Plane organization name',
71+
'',
5872
'### `/help`',
59-
'Shows this help message explaining available commands.',
73+
'Shows this help message explaining available commands and configuration.',
6074
'',
6175
'---',
62-
'_Note: These commands only work in pull request comments._'
76+
'**Note:** These commands only work in pull request comments.',
77+
'',
78+
'**Environment Setup:**',
79+
'1. Set required secrets in your repository settings:',
80+
' - `CPLN_TOKEN`',
81+
' - `CPLN_ORG`',
82+
'2. Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout'
6383
].join('\n');
6484
6585
await github.rest.issues.createComment({

0 commit comments

Comments
 (0)