# 🚀 CI/CD Setup Guide (For Developers) This project uses a centralized CI/CD system. You only need to configure **1 workflow file + secrets**. --- # 📁 1. Add Workflow File Create: ``` .gitea/workflows/ci.yml ``` Paste: ```yaml name: CI on: push: branches: [main, beta, staging, testing] pull_request: jobs: ci: uses: http://git.wdipl.com/Rajendra.Reddy/wdipl-actions/.gitea/workflows/ci.yml@main with: tech_stack: node # run_* flags: YAML true/false only (central workflow uses type: boolean). # If Sonar/Deploy were skipped while Build ran, you likely had type:string + bad coercion; # ensure these keys sit under `with:` (not `secrets:`) and names are run_sonar / run_deploy. run_build: true run_sonar: true run_deploy: true wait_for_quality_gate: 'false' app_path_beta: /var/www/app-beta app_path_staging: /var/www/app-staging app_path_prod: /var/www/app-prod pm2_id: app secrets: SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 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 }} ``` --- # 🔐 2. Add Secrets (Repo → Settings → Secrets) ## SonarQube | Name | Value | | -------------- | ------------------------ | | SONAR_HOST_URL | http://your-sonar-server | | SONAR_TOKEN | your sonar token | --- ## Beta / Testing Server | Name | Value | | -------------------- | -------------------------- | | BETA_SERVER_HOST | server IP/domain | | BETA_SERVER_PORT | 22 | | BETA_SERVER_USERNAME | ssh user (ubuntu/root) | | BETA_SERVER_PASSWORD | password (optional) | | BETA_SERVER_KEY | private ssh key (optional) | --- ## Staging Server | Name | Value | | ----------------------- | ------------------- | | STAGING_SERVER_HOST | server IP/domain | | STAGING_SERVER_PORT | 22 | | STAGING_SERVER_USERNAME | ssh user | | STAGING_SERVER_PASSWORD | password (optional) | | STAGING_SERVER_KEY | ssh key (optional) | --- ## Production Server | Name | Value | | -------------------- | ------------------- | | PROD_SERVER_HOST | server IP/domain | | PROD_SERVER_PORT | 22 | | PROD_SERVER_USERNAME | ssh user | | PROD_SERVER_PASSWORD | password (optional) | | PROD_SERVER_KEY | ssh key (optional) | --- # ⚙️ 3. Variables (Edit in ci.yml) | Variable | What to set | | --------------------- | ---------------------- | | tech_stack | node / react / nestjs | | run_build | true/false | | run_sonar | true/false | | run_deploy | true/false | | wait_for_quality_gate | true/false | | app_path_beta | path on beta server | | app_path_staging | path on staging server | | app_path_prod | path on prod server | | pm2_id | pm2 app name | --- # 🌿 4. Branch Behavior | Branch | Action | | ----------- | -------------------- | | feature/* | Build + Sonar | | develop | Build + Sonar | | testing | Deploy to Beta | | beta | Deploy to Beta | | staging | Deploy to Staging | | main / prod | Deploy to Production | --- # ⚙️ 5. What Happens on Deploy ```bash git fetch git reset --hard origin/ git pull npm install npm run build pm2 reload ``` --- # ⚠️ Notes * Use **either password OR SSH key** * Ensure server has: * Node.js * PM2 * Paths must exist on server * Deployment runs only if `run_deploy = true` --- # ✅ Summary 1. Add `ci.yml` 2. Add secrets 3. Set paths Done. ---