From bdf8c60ab963e44c907352ff0b58231167b3b07d Mon Sep 17 00:00:00 2001 From: Rajendra Reddy Date: Mon, 13 Apr 2026 02:01:32 +0000 Subject: [PATCH] Add .gitea/workflows/deploy.yml --- .gitea/workflows/deploy.yml | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..6d9d622 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,77 @@ +name: Klc-Learner-Frontend-CD + +on: + push: + branches: + - beta + - testing + - client + - staging + - production + +jobs: + deploy: + name: Deploying code in Server + runs-on: ubuntu-latest + + steps: + - name: Checkout Code in Runner + uses: actions/checkout@v3 + + - name: Determine Project Folder + run: | + echo "Detected Branch Name : ${{ gitea.ref_name }}" + BRANCH_NAME=${{ gitea.ref_name }} + + case "$BRANCH_NAME" in + beta) + echo "PROJECT_FOLDER=null" >> $GITHUB_ENV + ;; + testing) + echo "PROJECT_FOLDER=/home/klc/klc-frontend/Test_Release/KLC-Hr-Dashboard-Frontend" >> $GITHUB_ENV + ;; + client) + echo "PROJECT_FOLDER=null" >> $GITHUB_ENV + ;; + staging) + echo "PROJECT_FOLDER=null" >> $GITHUB_ENV + ;; + production) + echo "PROJECT_FOLDER=null" >> $GITHUB_ENV + ;; + *) + echo "UNKNOWN BRANCH" + exit 1 + ;; + esac + + echo "BRANCH_NAME=${{ gitea.ref_name }}" >> $GITHUB_ENV + + - name: Deploy Using SSH + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.BETA_SERVER_HOST }} + username: ${{ secrets.BETA_SERVER_USERNAME }} + password: ${{ secrets.BETA_SERVER_PASSWORD }} + port: ${{ secrets.BETA_SERVER_PORT }} + envs: BRANCH_NAME,PROJECT_FOLDER + script: | + set -e + + if [ "$PROJECT_FOLDER" = "null" ]; then + echo "No deployment configured for this branch" + exit 0 + fi + + cd $PROJECT_FOLDER + + git fetch + git reset --hard origin/$BRANCH_NAME + git stash && git stash clear || true + git pull origin $BRANCH_NAME + + echo "Installing Node Modules..." + npm install + + echo "Building..." + npm run build \ No newline at end of file