Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Actions separate to two jobs and staging #624

Merged
merged 11 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .github/actions/delete-control-plane-app/action.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/actions/delete-control-plane-app/delete-app.sh

This file was deleted.

98 changes: 0 additions & 98 deletions .github/actions/help-command/action.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/actions/validate-required-vars/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Validate Required Variables'
description: 'Validates that all required secrets and variables for Control Plane operations'

runs:
using: 'composite'
steps:
- name: Validate Required Secrets and Variables
shell: bash
run: |
missing=()

# Check required secrets
if [ -z "$CPLN_TOKEN_STAGING" ]; then
missing+=("Secret: CPLN_TOKEN_STAGING")
fi

# Check required variables
if [ -z "$CPLN_ORG_STAGING" ]; then
missing+=("Variable: CPLN_ORG_STAGING")
fi
if [ -z "$REVIEW_APP_PREFIX" ]; then
missing+=("Variable: REVIEW_APP_PREFIX")
fi

if [ ${#missing[@]} -ne 0 ]; then
echo "Required secrets/variables are not set: ${missing[*]}"
exit 1
fi
40 changes: 12 additions & 28 deletions .github/workflows/delete-review-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
types: [closed]
issue_comment:
types: [created]
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to delete review app for'
required: true
type: string

permissions:
contents: read
Expand All @@ -15,8 +21,8 @@ permissions:
env:
CPLN_ORG: ${{ vars.CPLN_ORG_STAGING }}
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}
APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number || github.event.issue.number }}
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
APP_NAME: ${{ vars.REVIEW_APP_PREFIX }}-pr-${{ github.event.pull_request.number || github.event.issue.number || inputs.pr_number }}
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number || inputs.pr_number }}

jobs:
debug:
Expand All @@ -29,37 +35,15 @@ jobs:
github.event.issue.pull_request &&
github.event.comment.body == '/delete-review-app') ||
(github.event_name == 'pull_request' &&
github.event.action == 'closed')
github.event.action == 'closed') ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

steps:
- name: Get PR number
id: pr
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.issue.number;
core.setOutput('pr_number', prNumber);
core.exportVariable('PR_NUMBER', prNumber);

- name: Set App Name
run: echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ env.PR_NUMBER }}" >> $GITHUB_ENV

- uses: actions/checkout@v4

- name: Validate Required Secrets
run: |
missing_secrets=()
for secret in "CPLN_TOKEN" "CPLN_ORG"; do
if [ -z "${!secret}" ]; then
missing_secrets+=("$secret")
fi
done

if [ ${#missing_secrets[@]} -ne 0 ]; then
echo "Required secrets are not set: ${missing_secrets[*]}"
exit 1
fi
- name: Validate Required Secrets and Variables
uses: ./.github/actions/validate-required-vars

- name: Setup Environment
uses: ./.github/actions/setup-environment
Expand Down
Loading
Loading