Skip to content

Commit 586dac3

Browse files
authored
Enhance GitHub Actions workflows for review app and staging deployments
- Improved job structure and branch validation - Added new jobs for debugging, building, and deploying applications - Refined management of environment and output variables - Simplified help command workflow with dynamic help text generation - Introduced manual execution trigger for deleting review apps - Adjusted formatting in review app help workflow - Expanded trigger conditions for deployment workflows Reviewed-on: #624
1 parent f0c726f commit 586dac3

File tree

10 files changed

+334
-314
lines changed

10 files changed

+334
-314
lines changed

Diff for: .github/actions/build-docker-image/action.yml

+11-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ inputs:
1313
required: true
1414
PR_NUMBER:
1515
description: 'PR number'
16-
required: true
16+
required: false
1717

1818
runs:
1919
using: "composite"
@@ -22,11 +22,18 @@ runs:
2222
id: build
2323
shell: bash
2424
run: |
25-
echo "🏗️ Building Docker image for PR #${PR_NUMBER} (commit ${{ inputs.commit }})..."
25+
PR_INFO=""
26+
if [ -n "${PR_NUMBER}" ]; then
27+
PR_INFO=" for PR #${PR_NUMBER}"
28+
fi
29+
30+
echo "🏗️ Building Docker image${PR_INFO} (commit ${{ inputs.commit }})..."
2631
2732
if cpflow build-image -a "${{ inputs.app_name }}" --commit="${{ inputs.commit }}" --org="${{ inputs.org }}"; then
28-
echo "✅ Docker image build successful for PR #${PR_NUMBER} (commit ${{ inputs.commit }})"
33+
image_tag="${{ inputs.org }}/${{ inputs.app_name }}:${{ inputs.commit }}"
34+
echo "image_tag=${image_tag}" >> $GITHUB_OUTPUT
35+
echo "✅ Docker image build successful${PR_INFO} (commit ${{ inputs.commit }})"
2936
else
30-
echo "❌ Docker image build failed for PR #${PR_NUMBER} (commit ${{ inputs.commit }})"
37+
echo "❌ Docker image build failed${PR_INFO} (commit ${{ inputs.commit }})"
3138
exit 1
3239
fi

Diff for: .github/actions/delete-control-plane-app/action.yml

-20
This file was deleted.

Diff for: .github/actions/delete-control-plane-app/delete-app.sh

-36
This file was deleted.

Diff for: .github/actions/help-command/action.yml

-98
This file was deleted.

Diff for: .github/actions/validate-required-vars/action.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'Validate Required Variables'
2+
description: 'Validates that all required secrets and variables for Control Plane operations'
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- name: Validate Required Secrets and Variables
8+
shell: bash
9+
run: |
10+
missing=()
11+
12+
# Check required secrets
13+
if [ -z "$CPLN_TOKEN_STAGING" ]; then
14+
missing+=("Secret: CPLN_TOKEN_STAGING")
15+
fi
16+
17+
# Check required variables
18+
if [ -z "$CPLN_ORG_STAGING" ]; then
19+
missing+=("Variable: CPLN_ORG_STAGING")
20+
fi
21+
if [ -z "$REVIEW_APP_PREFIX" ]; then
22+
missing+=("Variable: REVIEW_APP_PREFIX")
23+
fi
24+
25+
if [ ${#missing[@]} -ne 0 ]; then
26+
echo "Required secrets/variables are not set: ${missing[*]}"
27+
exit 1
28+
fi

Diff for: .github/workflows/delete-review-app.yml

+12-28
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ on:
55
types: [closed]
66
issue_comment:
77
types: [created]
8+
workflow_dispatch:
9+
inputs:
10+
pr_number:
11+
description: 'PR number to delete review app for'
12+
required: true
13+
type: string
814

915
permissions:
1016
contents: read
@@ -15,8 +21,8 @@ permissions:
1521
env:
1622
CPLN_ORG: ${{ vars.CPLN_ORG_STAGING }}
1723
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}
18-
APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number || github.event.issue.number }}
19-
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
24+
APP_NAME: ${{ vars.REVIEW_APP_PREFIX }}-pr-${{ github.event.pull_request.number || github.event.issue.number || inputs.pr_number }}
25+
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number || inputs.pr_number }}
2026

2127
jobs:
2228
debug:
@@ -29,37 +35,15 @@ jobs:
2935
github.event.issue.pull_request &&
3036
github.event.comment.body == '/delete-review-app') ||
3137
(github.event_name == 'pull_request' &&
32-
github.event.action == 'closed')
38+
github.event.action == 'closed') ||
39+
github.event_name == 'workflow_dispatch'
3340
runs-on: ubuntu-latest
3441

3542
steps:
36-
- name: Get PR number
37-
id: pr
38-
uses: actions/github-script@v7
39-
with:
40-
script: |
41-
const prNumber = context.payload.issue.number;
42-
core.setOutput('pr_number', prNumber);
43-
core.exportVariable('PR_NUMBER', prNumber);
44-
45-
- name: Set App Name
46-
run: echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ env.PR_NUMBER }}" >> $GITHUB_ENV
47-
4843
- uses: actions/checkout@v4
4944

50-
- name: Validate Required Secrets
51-
run: |
52-
missing_secrets=()
53-
for secret in "CPLN_TOKEN" "CPLN_ORG"; do
54-
if [ -z "${!secret}" ]; then
55-
missing_secrets+=("$secret")
56-
fi
57-
done
58-
59-
if [ ${#missing_secrets[@]} -ne 0 ]; then
60-
echo "Required secrets are not set: ${missing_secrets[*]}"
61-
exit 1
62-
fi
45+
- name: Validate Required Secrets and Variables
46+
uses: ./.github/actions/validate-required-vars
6347

6448
- name: Setup Environment
6549
uses: ./.github/actions/setup-environment

0 commit comments

Comments
 (0)