Skip to content

Commit 66701a4

Browse files
authored
Merge 1ca2e06 into 586dac3
2 parents 586dac3 + 1ca2e06 commit 66701a4

File tree

6 files changed

+117
-58
lines changed

6 files changed

+117
-58
lines changed

.controlplane/controlplane.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,24 @@ aliases:
3939

4040
apps:
4141
react-webpack-rails-tutorial-production:
42-
# Simulate Production Version
42+
# Simulate Production Version. Create with this command:
43+
# cpflow apply-template app postgres redis daily-task rails -a react-webpack-rails-tutorial-production -o shakacode-open-source-examples-production
4344
<<: *common
4445
# Don't allow overriding the org and app by ENV vars b/c production is sensitive!
4546
allow_org_override_by_env: false
4647
allow_app_override_by_env: false
4748

48-
# Use a different organization for production.
49-
cpln_org: shakacode-open-source-examples
49+
# Use a different organization only for production.
50+
cpln_org: shakacode-open-source-examples-production
5051

5152
upstream: react-webpack-rails-tutorial-staging
5253

5354
react-webpack-rails-tutorial-staging:
5455
<<: *common
55-
# QA Apps are like Heroku review apps, but the use `prefix` so you can run a commmand like
56-
# this to create a QA app for the tutorial app.
57-
# `cpflow setup gvc postgres redis rails -a qa-react-webpack-rails-tutorial-pr-1234`
5856
qa-react-webpack-rails-tutorial:
57+
# Review Apps are like Heroku review apps, but the use `prefix` so you can run a command like
58+
# this to create a QA app for the tutorial app.
59+
# `cpflow setup-app -a qa-react-webpack-rails-tutorial-pr-1234`
5960
<<: *common
6061
# Order matters!
6162
setup_app_templates:
Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
name: 'Validate Required Variables'
22
description: 'Validates that all required secrets and variables for Control Plane operations'
33

4+
inputs:
5+
CPLN_TOKEN_STAGING:
6+
required: true
7+
description: 'Control Plane Staging Token'
8+
CPLN_TOKEN_PRODUCTION:
9+
required: true
10+
description: 'Control Plane Production Token'
11+
CPLN_ORG_STAGING:
12+
required: true
13+
description: 'Control Plane Staging Organization'
14+
CPLN_ORG_PRODUCTION:
15+
required: true
16+
description: 'Control Plane Production Organization'
17+
REVIEW_APP_PREFIX:
18+
required: true
19+
description: 'Review App Prefix'
20+
PRODUCTION_APP_NAME:
21+
required: true
22+
description: 'Production App Name'
23+
STAGING_APP_NAME:
24+
required: true
25+
description: 'Staging App Name'
26+
427
runs:
528
using: 'composite'
629
steps:
@@ -10,19 +33,37 @@ runs:
1033
missing=()
1134
1235
# Check required secrets
13-
if [ -z "$CPLN_TOKEN_STAGING" ]; then
36+
if [ -z "${{ inputs.CPLN_TOKEN_STAGING }}" ]; then
1437
missing+=("Secret: CPLN_TOKEN_STAGING")
1538
fi
39+
40+
if [ -z "${{ inputs.CPLN_TOKEN_PRODUCTION }}" ]; then
41+
missing+=("Secret: CPLN_TOKEN_PRODUCTION")
42+
fi
1643
1744
# Check required variables
18-
if [ -z "$CPLN_ORG_STAGING" ]; then
45+
if [ -z "${{ inputs.CPLN_ORG_STAGING }}" ]; then
1946
missing+=("Variable: CPLN_ORG_STAGING")
2047
fi
21-
if [ -z "$REVIEW_APP_PREFIX" ]; then
48+
49+
if [ -z "${{ inputs.CPLN_ORG_PRODUCTION }}" ]; then
50+
missing+=("Variable: CPLN_ORG_PRODUCTION")
51+
fi
52+
53+
if [ -z "${{ inputs.REVIEW_APP_PREFIX }}" ]; then
2254
missing+=("Variable: REVIEW_APP_PREFIX")
2355
fi
56+
57+
if [ -z "${{ inputs.PRODUCTION_APP_NAME }}" ]; then
58+
missing+=("Variable: PRODUCTION_APP_NAME")
59+
fi
60+
61+
if [ -z "${{ inputs.STAGING_APP_NAME }}" ]; then
62+
missing+=("Variable: STAGING_APP_NAME")
63+
fi
2464
2565
if [ ${#missing[@]} -ne 0 ]; then
26-
echo "Required secrets/variables are not set: ${missing[*]}"
66+
echo "Missing required secrets/variables:"
67+
printf '%s\n' "${missing[@]}"
2768
exit 1
2869
fi

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ jobs:
4444

4545
- name: Validate Required Secrets and Variables
4646
uses: ./.github/actions/validate-required-vars
47+
with:
48+
CPLN_TOKEN_STAGING: ${{ secrets.CPLN_TOKEN_STAGING }}
49+
CPLN_TOKEN_PRODUCTION: ${{ secrets.CPLN_TOKEN_PRODUCTION }}
50+
CPLN_ORG_STAGING: ${{ vars.CPLN_ORG_STAGING }}
51+
CPLN_ORG_PRODUCTION: ${{ vars.CPLN_ORG_PRODUCTION }}
52+
REVIEW_APP_PREFIX: ${{ vars.REVIEW_APP_PREFIX }}
53+
PRODUCTION_APP_NAME: ${{ vars.PRODUCTION_APP_NAME }}
54+
STAGING_APP_NAME: ${{ vars.STAGING_APP_NAME }}
4755

4856
- name: Setup Environment
4957
uses: ./.github/actions/setup-environment
@@ -108,7 +116,6 @@ jobs:
108116
issue_number: process.env.PR_NUMBER,
109117
owner: context.repo.owner,
110118
repo: context.repo.repo,
111-
body: '🗑️ Starting app deletion...'
112119
body: [
113120
message,
114121
'',
@@ -125,10 +132,6 @@ jobs:
125132
app_name: ${{ env.APP_NAME }}
126133
org: ${{ env.CPLN_ORG }}
127134
github_token: ${{ secrets.GITHUB_TOKEN }}
128-
env:
129-
APP_NAME: ${{ env.APP_NAME }}
130-
CPLN_ORG: ${{ secrets.CPLN_ORG }}
131-
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
132135

133136
- name: Update Delete Status
134137
if: always()
@@ -163,3 +166,15 @@ jobs:
163166
comment_id: ${{ fromJSON(steps.create-delete-comment.outputs.result).commentId }},
164167
body: success ? successMessage : failureMessage
165168
});
169+
170+
- name: Debug Environment
171+
run: |
172+
echo "Organization: ${{ env.CPLN_ORG }}"
173+
echo "App Name: ${{ env.APP_NAME }}"
174+
echo "PR Number: ${{ env.PR_NUMBER }}"
175+
# Don't echo the actual token, but verify it exists
176+
if [ -n "${{ env.CPLN_TOKEN }}" ]; then
177+
echo "CPLN_TOKEN is set"
178+
else
179+
echo "CPLN_TOKEN is empty"
180+
fi

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

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ jobs:
7171

7272
- name: Validate Required Secrets and Variables
7373
uses: ./.github/actions/validate-required-vars
74+
with:
75+
CPLN_TOKEN_STAGING: ${{ secrets.CPLN_TOKEN_STAGING }}
76+
CPLN_TOKEN_PRODUCTION: ${{ secrets.CPLN_TOKEN_PRODUCTION }}
77+
CPLN_ORG_STAGING: ${{ vars.CPLN_ORG_STAGING }}
78+
CPLN_ORG_PRODUCTION: ${{ vars.CPLN_ORG_PRODUCTION }}
79+
REVIEW_APP_PREFIX: ${{ vars.REVIEW_APP_PREFIX }}
80+
PRODUCTION_APP_NAME: ${{ vars.PRODUCTION_APP_NAME }}
81+
STAGING_APP_NAME: ${{ vars.STAGING_APP_NAME }}
7482

7583
- name: Get PR HEAD Ref
7684
id: getRef
@@ -222,7 +230,13 @@ jobs:
222230
owner: context.repo.owner,
223231
repo: context.repo.repo,
224232
issue_number: process.env.PR_NUMBER,
225-
body: '🚀 Starting deployment process...\n\n' + process.env.CONSOLE_LINK
233+
body: [
234+
`🏗️ Building Docker image for PR [#${process.env.PR_NUMBER}](${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/pull/${process.env.PR_NUMBER}), commit [${context.sha.substring(0, 7)}](${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/commit/${context.sha})`,
235+
'',
236+
`📝 [View Build Logs](${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${context.job})`,
237+
'',
238+
process.env.CONSOLE_LINK
239+
].join('\n')
226240
});
227241
core.setOutput('comment-id', result.data.id);
228242
@@ -309,25 +323,6 @@ jobs:
309323
token: ${{ secrets.CPLN_TOKEN_STAGING }}
310324
org: ${{ vars.CPLN_ORG_STAGING }}
311325

312-
- name: Update Status - Building
313-
uses: actions/github-script@v7
314-
with:
315-
script: |
316-
const buildingMessage = [
317-
'🏗️ Building Docker image for PR #${{ needs.process-deployment.outputs.pr_number }}, commit ${{ needs.process-deployment.outputs.pr_sha }}',
318-
'',
319-
'📝 [View Build Logs](${{ env.WORKFLOW_URL }})',
320-
'',
321-
process.env.CONSOLE_LINK
322-
].join('\n');
323-
324-
await github.rest.issues.updateComment({
325-
owner: context.repo.owner,
326-
repo: context.repo.repo,
327-
comment_id: ${{ needs.process-deployment.outputs.comment_id }},
328-
body: buildingMessage
329-
});
330-
331326
- name: Build Docker Image
332327
id: build
333328
uses: ./.github/actions/build-docker-image
@@ -368,7 +363,7 @@ jobs:
368363
await github.rest.issues.updateComment({
369364
owner: context.repo.owner,
370365
repo: context.repo.repo,
371-
comment_id: ${{ steps.create-comment.outputs.comment-id }},
366+
comment_id: ${{ needs.build.outputs.comment_id }},
372367
body: deployingMessage
373368
});
374369

.github/workflows/help-command.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ jobs:
1818
help:
1919
if: ${{ (github.event.issue.pull_request && github.event.comment.body == '/help') || github.event_name == 'workflow_dispatch' }}
2020
runs-on: ubuntu-latest
21-
21+
2222
steps:
2323
- name: Show Available Commands
2424
uses: actions/github-script@v7
2525
with:
2626
script: |
2727
const sections = {
2828
commands: {
29-
deploy: {
30-
title: '## `/deploy`',
29+
"deploy-review-app": {
30+
title: '## `/deploy-review-app`',
3131
purpose: '**Purpose:** Deploy a review app for your pull request',
3232
details: [
3333
'**What it does:**',
@@ -42,8 +42,8 @@ jobs:
4242
' - Example: `/deploy timeout=1800`'
4343
]
4444
},
45-
destroy: {
46-
title: '## `/destroy`',
45+
"delete-review-app: {
46+
title: '## `/delete-review-app`',
4747
purpose: '**Purpose:** Remove the review app for your pull request',
4848
details: [
4949
'**What it does:**',
@@ -96,17 +96,18 @@ jobs:
9696
details: [
9797
'Review apps are automatically destroyed when:',
9898
'1. The pull request is closed',
99-
'2. The `/destroy` command is used',
99+
'2. The `/delete-review-app` command is used',
100100
'3. A new deployment is requested (old one is cleaned up first)'
101101
]
102102
},
103103
help: {
104104
title: '## Need Help?',
105105
details: [
106-
'For additional assistance:',
107-
'1. Check the [Control Plane documentation](https://docs.controlplane.com/)',
106+
'For additional assistance, ',
107+
'1. Check the [Control Plane Flow documentation](https://www.shakacode.com/control-plane-flow/docs/)',
108108
'2. Contact the infrastructure team',
109-
'3. Open an issue in this repository'
109+
'3. [Open an issue in this repository](https://github.com/shakacode/control-plane-flow/issues/new)',
110+
'4. [Contact ShakaCode support](mailto:[email protected])'
110111
]
111112
}
112113
};
@@ -148,4 +149,3 @@ jobs:
148149
issue_number: prNumber,
149150
body: helpText
150151
});
151-

.github/workflows/promote-staging-to-production.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,43 @@ on:
99
type: string
1010

1111
jobs:
12+
debug:
13+
uses: ./.github/workflows/debug-workflow.yml
14+
with:
15+
debug_enabled: false
16+
1217
promote-to-production:
1318
runs-on: ubuntu-latest
1419
if: github.event.inputs.confirm_promotion == 'promote'
15-
20+
1621
env:
17-
APP_NAME: react-webpack-rails-tutorial
18-
CPLN_ORG: ${{ secrets.CPLN_ORG }}
19-
UPSTREAM_TOKEN: ${{ secrets.STAGING_TOKEN }}
20-
22+
APP_NAME: ${{ vars.PRODUCTION_APP_NAME }}
23+
CPLN_ORG: ${{ vars.CPLN_ORG_PRODUCTION }}
24+
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_PRODUCTION }}
25+
UPSTREAM_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}
26+
2127
steps:
2228
- name: Checkout code
2329
uses: actions/checkout@v4
24-
30+
2531
- name: Setup Environment
2632
uses: ./.github/actions/setup-environment
27-
env:
28-
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
29-
33+
with:
34+
token: ${{ secrets.CPLN_TOKEN_PRODUCTION }}
35+
org: ${{ vars.CPLN_ORG_PRODUCTION }}
36+
3037
- name: Promote Staging to Production
3138
id: promote
3239
run: |
33-
echo "🚀 Starting promotion from staging to production..."
40+
echo "🚀 Starting promotion from staging to production... for app ${APP_NAME}"
3441
35-
if ! cpflow promote-app-from-upstream -a "${APP_NAME}" -t "${UPSTREAM_TOKEN}" --org "${CPLN_ORG}"; then
42+
if ! cpflow promote-app-from-upstream -a "${APP_NAME}" -t "${UPSTREAM_TOKEN}" --org "${CPLN_ORG}" --verbose --trace ; then
3643
echo "❌ Failed to promote staging to production"
3744
exit 1
3845
fi
3946
4047
echo "✅ Successfully promoted staging to production"
41-
48+
4249
- name: Create GitHub Release
4350
if: success()
4451
env:

0 commit comments

Comments
 (0)