From 6815d4fbfd58c42ce4f344aa3d1927286b26e347 Mon Sep 17 00:00:00 2001 From: Rajendra Reddy Date: Tue, 7 Apr 2026 09:45:03 +0000 Subject: [PATCH] Update .gitea/workflows/deploy.yml --- .gitea/workflows/deploy.yml | 166 +++++++++++++++++++++++++++++++++ .gitea/workflows/deploybak.yml | 82 ---------------- 2 files changed, 166 insertions(+), 82 deletions(-) create mode 100644 .gitea/workflows/deploy.yml delete mode 100644 .gitea/workflows/deploybak.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..b95e126 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,166 @@ +name: Deploy + +on: + workflow_call: + inputs: + tech_stack: + required: true + type: string + branch_name: + required: true + type: string + + app_path_beta: + required: false + type: string + app_path_staging: + required: false + type: string + app_path_prod: + required: false + type: string + + pm2_id: + required: false + type: string + + secrets: + 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: + deploy: + runs-on: ubuntu-latest + + steps: + + # 🔹 BETA / TESTING + - name: Deploy Beta/Testing + if: inputs.branch_name == 'beta' || inputs.branch_name == 'testing' + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.BETA_SERVER_HOST }} + username: ${{ secrets.BETA_SERVER_USERNAME }} + port: ${{ secrets.BETA_SERVER_PORT }} + password: ${{ secrets.BETA_SERVER_PASSWORD }} + key: ${{ secrets.BETA_SERVER_KEY }} + + script: | + set -xe + cd ${{ inputs.app_path_beta }} + + git fetch + git reset --hard origin/${{ inputs.branch_name }} + git pull origin ${{ inputs.branch_name }} + + case "${{ inputs.tech_stack }}" in + node|react|nestjs) + npm install + npm run build || true + pm2 reload ${{ inputs.pm2_id }} || true + ;; + docker) + docker compose up -d --build + ;; + *) + echo "Unknown tech" + ;; + esac + + + # 🔹 STAGING + - name: Deploy Staging + if: inputs.branch_name == 'staging' + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.STAGING_SERVER_HOST }} + username: ${{ secrets.STAGING_SERVER_USERNAME }} + port: ${{ secrets.STAGING_SERVER_PORT }} + password: ${{ secrets.STAGING_SERVER_PASSWORD }} + key: ${{ secrets.STAGING_SERVER_KEY }} + + script: | + set -xe + cd ${{ inputs.app_path_staging }} + + git fetch + git reset --hard origin/${{ inputs.branch_name }} + git pull origin ${{ inputs.branch_name }} + + case "${{ inputs.tech_stack }}" in + node|react|nestjs) + npm install + npm run build || true + pm2 reload ${{ inputs.pm2_id }} || true + ;; + docker) + docker compose up -d --build + ;; + *) + echo "Unknown tech" + ;; + esac + + + # 🔹 PRODUCTION + - name: Deploy Production + if: inputs.branch_name == 'main' || inputs.branch_name == 'prod' + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.PROD_SERVER_HOST }} + username: ${{ secrets.PROD_SERVER_USERNAME }} + port: ${{ secrets.PROD_SERVER_PORT }} + password: ${{ secrets.PROD_SERVER_PASSWORD }} + key: ${{ secrets.PROD_SERVER_KEY }} + + script: | + set -xe + cd ${{ inputs.app_path_prod }} + + git fetch + git reset --hard origin/${{ inputs.branch_name }} + git pull origin ${{ inputs.branch_name }} + + case "${{ inputs.tech_stack }}" in + node|react|nestjs) + npm install + npm run build || true + pm2 reload ${{ inputs.pm2_id }} || true + ;; + docker) + docker compose up -d --build + ;; + *) + echo "Unknown tech" + ;; + esac \ No newline at end of file diff --git a/.gitea/workflows/deploybak.yml b/.gitea/workflows/deploybak.yml deleted file mode 100644 index 39b1a06..0000000 --- a/.gitea/workflows/deploybak.yml +++ /dev/null @@ -1,82 +0,0 @@ -on: - workflow_call: - inputs: - host: - required: true - type: string - username: - required: true - type: string - port: - required: true - type: number - project_folder: - required: true - type: string - pm2_id: - required: false - type: string - branch_name: - required: true - type: string - tech: - required: true - type: string - - secrets: - password: - required: false - key: - required: false - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - name: Deploy via SSH - uses: appleboy/ssh-action@v1 - with: - host: ${{ inputs.host }} - username: ${{ inputs.username }} - password: ${{ secrets.password }} - key: ${{ secrets.key }} - port: ${{ inputs.port }} - - script: | - set -xe - - cd ${{ inputs.project_folder }} - - git fetch - git reset --hard origin/${{ inputs.branch_name }} - git pull origin ${{ inputs.branch_name }} - - echo "Installing deps" - npm install - - echo "Running tech-specific steps" - case "${{ inputs.tech }}" in - node) - npm i - npx prisma generate - npx prisma migrate deploy - npm run build - pm2 reload ${{ inputs.pm2_id }} - ;; - nestjs) - npm i - npx prisma generate - npx prisma migrate deploy - npm run build - pm2 reload ${{ inputs.pm2_id }} - ;; - python) - docker-compose up -d --build - ;; - *) - echo "Unknown tech" - ;; - esac - - \ No newline at end of file