Remove unused inputs and the extra meta job, and keep a single stable flow where build snapshots ci_steps for sonar/deploy conditions. Made-with: Cursor
144 lines
4.3 KiB
YAML
144 lines
4.3 KiB
YAML
name: Central CI
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
ci_steps:
|
|
type: string
|
|
required: true
|
|
wait_for_quality_gate:
|
|
type: string
|
|
required: false
|
|
tech_stack:
|
|
type: string
|
|
required: true
|
|
|
|
app_path_beta:
|
|
type: string
|
|
required: false
|
|
app_path_staging:
|
|
type: string
|
|
required: false
|
|
app_path_prod:
|
|
type: string
|
|
required: false
|
|
build_command:
|
|
type: string
|
|
required: false
|
|
pm2_id:
|
|
type: string
|
|
required: false
|
|
|
|
secrets:
|
|
SONARQUBE_HOST:
|
|
required: false
|
|
SONARQUBE_TOKEN:
|
|
required: false
|
|
|
|
BETA_SERVER_HOST:
|
|
required: false
|
|
BETA_SERVER_PORT:
|
|
required: false
|
|
BETA_SERVER_USERNAME:
|
|
required: false
|
|
BETA_SERVER_PASSWORD:
|
|
required: false
|
|
BETA_SERVER_KEY:
|
|
required: false
|
|
|
|
STAGING_SERVER_HOST:
|
|
required: false
|
|
STAGING_SERVER_PORT:
|
|
required: false
|
|
STAGING_SERVER_USERNAME:
|
|
required: false
|
|
STAGING_SERVER_PASSWORD:
|
|
required: false
|
|
STAGING_SERVER_KEY:
|
|
required: false
|
|
|
|
PROD_SERVER_HOST:
|
|
required: false
|
|
PROD_SERVER_PORT:
|
|
required: false
|
|
PROD_SERVER_USERNAME:
|
|
required: false
|
|
PROD_SERVER_PASSWORD:
|
|
required: false
|
|
PROD_SERVER_KEY:
|
|
required: false
|
|
|
|
jobs:
|
|
build:
|
|
if: ${{ contains(format(',{0},', inputs.ci_steps), ',build,') }}
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
cs: ${{ steps.capture.outputs.cs }}
|
|
steps:
|
|
- id: capture
|
|
name: Capture ci_steps
|
|
run: echo "cs=${{ inputs.ci_steps }}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Node
|
|
if: inputs.tech_stack == 'node' || inputs.tech_stack == 'react' || inputs.tech_stack == 'nestjs'
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Build (Node / React / NestJS)
|
|
if: inputs.tech_stack == 'node' || inputs.tech_stack == 'react' || inputs.tech_stack == 'nestjs'
|
|
run: |
|
|
if [ -n "${{ inputs.build_command }}" ]; then
|
|
set -xe
|
|
echo "Running custom build command"
|
|
${{ inputs.build_command }}
|
|
else
|
|
set -xe
|
|
npm install
|
|
npm run build
|
|
fi
|
|
|
|
sonar:
|
|
if: ${{ contains(format(',{0},', needs.build.outputs.cs), ',sonar,') }}
|
|
needs: [build]
|
|
uses: Rajendra.Reddy/wdipl-actions/.gitea/workflows/quality.yml@d604440af823c664b2c828a3d6a2cc5d23b79141
|
|
with:
|
|
project_key: ${{ github.event.repository.name }}
|
|
wait_for_quality_gate: ${{ inputs.wait_for_quality_gate }}
|
|
secrets:
|
|
SONARQUBE_HOST: ${{ secrets.SONARQUBE_HOST }}
|
|
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
|
|
|
|
deploy:
|
|
if: ${{ always() && contains(format(',{0},', needs.build.outputs.cs), ',deploy,') && needs.build.result == 'success' && (needs.sonar.result == 'success' || needs.sonar.result == 'skipped') }}
|
|
needs: [build, sonar]
|
|
uses: Rajendra.Reddy/wdipl-actions/.gitea/workflows/deploy.yml@main
|
|
with:
|
|
tech_stack: ${{ inputs.tech_stack }}
|
|
branch_name: ${{ github.ref_name }}
|
|
pm2_id: ${{ inputs.pm2_id }}
|
|
app_path_beta: ${{ inputs.app_path_beta }}
|
|
app_path_staging: ${{ inputs.app_path_staging }}
|
|
app_path_prod: ${{ inputs.app_path_prod }}
|
|
secrets:
|
|
BETA_SERVER_HOST: ${{ secrets.BETA_SERVER_HOST }}
|
|
BETA_SERVER_PORT: ${{ secrets.BETA_SERVER_PORT }}
|
|
BETA_SERVER_USERNAME: ${{ secrets.BETA_SERVER_USERNAME }}
|
|
BETA_SERVER_PASSWORD: ${{ secrets.BETA_SERVER_PASSWORD }}
|
|
BETA_SERVER_KEY: ${{ secrets.BETA_SERVER_KEY }}
|
|
|
|
STAGING_SERVER_HOST: ${{ secrets.STAGING_SERVER_HOST }}
|
|
STAGING_SERVER_PORT: ${{ secrets.STAGING_SERVER_PORT }}
|
|
STAGING_SERVER_USERNAME: ${{ secrets.STAGING_SERVER_USERNAME }}
|
|
STAGING_SERVER_PASSWORD: ${{ secrets.STAGING_SERVER_PASSWORD }}
|
|
STAGING_SERVER_KEY: ${{ secrets.STAGING_SERVER_KEY }}
|
|
|
|
PROD_SERVER_HOST: ${{ secrets.PROD_SERVER_HOST }}
|
|
PROD_SERVER_PORT: ${{ secrets.PROD_SERVER_PORT }}
|
|
PROD_SERVER_USERNAME: ${{ secrets.PROD_SERVER_USERNAME }}
|
|
PROD_SERVER_PASSWORD: ${{ secrets.PROD_SERVER_PASSWORD }}
|
|
PROD_SERVER_KEY: ${{ secrets.PROD_SERVER_KEY }}
|