Skip to content

Commit 8a6212e

Browse files
committed
validations
1 parent 7d2f639 commit 8a6212e

File tree

5 files changed

+41
-106
lines changed

5 files changed

+41
-106
lines changed

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

-20
This file was deleted.

.github/actions/delete-control-plane-app/delete-app.sh

-36
This file was deleted.
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

.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

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

+1-22
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,7 @@ jobs:
7070
fetch-depth: 0
7171

7272
- name: Validate Required Secrets and Variables
73-
shell: bash
74-
run: |
75-
missing=()
76-
77-
# Check secrets
78-
if [ -z "${{ secrets.CPLN_TOKEN_STAGING }}" ]; then
79-
missing+=("Secret: CPLN_TOKEN_STAGING")
80-
fi
81-
82-
# Check variables
83-
if [ -z "${{ vars.CPLN_ORG_STAGING }}" ]; then
84-
missing+=("Variable: CPLN_ORG_STAGING")
85-
fi
86-
87-
if [ -z "${{ vars.REVIEW_APP_PREFIX }}" ]; then
88-
missing+=("Variable: REVIEW_APP_PREFIX")
89-
fi
90-
91-
if [ ${#missing[@]} -ne 0 ]; then
92-
echo "Required secrets/variables are not set: ${missing[*]}"
93-
exit 1
94-
fi
73+
uses: ./.github/actions/validate-required-vars
9574

9675
- name: Get PR HEAD Ref
9776
id: getRef

0 commit comments

Comments
 (0)