Skip to content

Commit f0c726f

Browse files
authored
get PR review apps working again (#623)
1 parent ebbc8d8 commit f0c726f

File tree

10 files changed

+262
-160
lines changed

10 files changed

+262
-160
lines changed

.github/actions/delete-control-plane-app/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ runs:
1414
steps:
1515
- name: Delete Application
1616
shell: bash
17-
run: ${{ github.action_path }}/../deploy-to-control-plane/scripts/delete-app.sh
17+
run: ${{ github.action_path }}/scripts/delete-app.sh
1818
env:
1919
APP_NAME: ${{ inputs.app_name }}
2020
CPLN_ORG: ${{ inputs.org }}

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

+5-69
Original file line numberDiff line numberDiff line change
@@ -32,80 +32,16 @@ outputs:
3232
runs:
3333
using: "composite"
3434
steps:
35-
- name: Validate Required Secrets
36-
shell: bash
37-
run: |
38-
missing_secrets=()
39-
for secret in "CPLN_TOKEN" "CPLN_ORG"; do
40-
if [ -z "${!secret}" ]; then
41-
missing_secrets+=("$secret")
42-
fi
43-
done
44-
45-
if [ ${#missing_secrets[@]} -ne 0 ]; then
46-
echo "Required secrets are not set: ${missing_secrets[*]}"
47-
exit 1
48-
fi
49-
50-
- name: Setup Environment
51-
uses: ./.github/actions/setup-environment
52-
53-
- name: Get Commit SHA
54-
id: get_sha
55-
shell: bash
56-
run: ${{ github.action_path }}/scripts/get-commit-sha.sh
57-
env:
58-
GITHUB_TOKEN: ${{ inputs.github_token }}
59-
PR_NUMBER: ${{ inputs.pr_number }}
60-
6135
- name: Deploy to Control Plane
6236
id: deploy
6337
shell: bash
6438
env:
39+
APP_NAME: ${{ inputs.app_name }}
40+
CPLN_ORG: ${{ inputs.org }}
6541
CPLN_TOKEN: ${{ inputs.cpln_token }}
66-
PR_NUMBER: ${{ inputs.pr_number }}
42+
WAIT_TIMEOUT: ${{ inputs.wait_timeout }}
6743
run: |
68-
echo "🚀 Deploying app for PR #${PR_NUMBER}..."
69-
70-
# Create temp file for output
71-
TEMP_OUTPUT=$(mktemp)
72-
trap 'rm -f "${TEMP_OUTPUT}"' EXIT
73-
74-
# Deploy the application and show output in real-time while capturing it
75-
if ! cpflow deploy-image -a "${{ inputs.app_name }}" --run-release-phase --org "${{ inputs.org }}" 2>&1 | tee "${TEMP_OUTPUT}"; then
76-
echo "❌ Deployment failed for PR #${PR_NUMBER}"
77-
echo "Error output:"
78-
cat "${TEMP_OUTPUT}"
79-
exit 1
80-
fi
81-
82-
# Extract app URL from captured output
83-
REVIEW_APP_URL=$(grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' "${TEMP_OUTPUT}" | head -n1)
84-
if [ -z "${REVIEW_APP_URL}" ]; then
85-
echo "❌ Failed to get app URL from deployment output"
86-
echo "Deployment output:"
87-
cat "${TEMP_OUTPUT}"
88-
exit 1
89-
fi
90-
91-
# Wait for all workloads to be ready
92-
WAIT_TIMEOUT=${WAIT_TIMEOUT:-${{ inputs.wait_timeout }}}
93-
echo "⏳ Waiting for all workloads to be ready (timeout: ${WAIT_TIMEOUT}s)..."
94-
95-
# Use timeout command with ps:wait and show output in real-time
96-
if ! timeout "${WAIT_TIMEOUT}" bash -c "cpflow ps:wait -a \"${{ inputs.app_name }}\"" 2>&1 | tee -a "${TEMP_OUTPUT}"; then
97-
TIMEOUT_EXIT=$?
98-
if [ ${TIMEOUT_EXIT} -eq 124 ]; then
99-
echo "❌ Timed out waiting for workloads after ${WAIT_TIMEOUT} seconds"
100-
else
101-
echo "❌ Workloads did not become ready for PR #${PR_NUMBER} (exit code: ${TIMEOUT_EXIT})"
102-
fi
103-
echo "Full output:"
104-
cat "${TEMP_OUTPUT}"
44+
# Run the deployment script
45+
if ! ${{ github.action_path }}/scripts/deploy.sh; then
10546
exit 1
10647
fi
107-
108-
echo "✅ Deployment successful for PR #${PR_NUMBER}"
109-
echo "🌐 App URL: ${REVIEW_APP_URL}"
110-
echo "review_app_url=${REVIEW_APP_URL}" >> $GITHUB_OUTPUT
111-
echo "REVIEW_APP_URL=${REVIEW_APP_URL}" >> $GITHUB_ENV

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

+6-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Must be a positive integer
1212
#
1313
# Outputs:
14-
# - rails_url: URL of the deployed Rails application
14+
# - ENV APP_URL: URL of the deployed application
1515

1616
set -e
1717

@@ -39,11 +39,9 @@ if ! timeout "${WAIT_TIMEOUT}" cpflow deploy-image -a "$APP_NAME" --run-release-
3939
fi
4040

4141
# Extract app URL from deployment output
42-
RAILS_URL=$(grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1)
43-
if [ -z "$RAILS_URL" ]; then
44-
echo "❌ Failed to get app URL from deployment output"
45-
echo "Full output:"
46-
cat "$TEMP_OUTPUT"
42+
APP_URL=$(grep -oP 'https://[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1)
43+
if [ -z "$APP_URL" ]; then
44+
echo "❌ Error: Could not find app URL in deployment output"
4745
exit 1
4846
fi
4947

@@ -62,5 +60,5 @@ if ! timeout "${WAIT_TIMEOUT}" bash -c "cpflow ps:wait -a \"$APP_NAME\"" 2>&1 |
6260
fi
6361

6462
echo "✅ Deployment successful"
65-
echo "🌐 Rails URL: $RAILS_URL"
66-
echo "rails_url=$RAILS_URL" >> "$GITHUB_OUTPUT"
63+
echo "🌐 App URL: $APP_URL"
64+
echo "APP_URL=$APP_URL" >> "$GITHUB_OUTPUT"

.github/actions/deploy-to-control-plane/scripts/get-commit-sha.sh

-34
This file was deleted.

.github/workflows/debug-workflow.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Debug Workflow Information
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
debug_enabled:
7+
required: false
8+
type: boolean
9+
default: false
10+
description: 'Enable debug logging (defaults to false)'
11+
12+
jobs:
13+
debug-info:
14+
runs-on: ubuntu-latest
15+
if: inputs.debug_enabled || vars.DEBUG_WORKFLOW == 'true'
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Log Branch Info
22+
run: |
23+
echo "Branch for this run:"
24+
if [ "${{ github.event_name }}" == "pull_request" ]; then
25+
echo "Pull Request Source Branch: ${{ github.head_ref }}"
26+
else
27+
echo "Branch: ${{ github.ref_name }}"
28+
fi
29+
30+
- name: Debug GitHub Context
31+
run: |
32+
echo "Event name: ${{ github.event_name }}"
33+
echo "Event path: ${{ github.event_path }}"
34+
echo "Repository: ${{ github.repository }}"
35+
echo "Full GitHub context:"
36+
echo '${{ toJson(github) }}'

.github/workflows/delete-review-app.yml

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ env:
1919
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
2020

2121
jobs:
22+
debug:
23+
uses: ./.github/workflows/debug-workflow.yml
24+
with:
25+
debug_enabled: false # Will still run if vars.DEBUG_WORKFLOW is true
2226
Process-Delete-Command:
2327
if: |
2428
(github.event_name == 'issue_comment' &&

0 commit comments

Comments
 (0)