Files
KLC-Hr-Dashboard-Frontend/.gitea/workflows/deploy.yml
Rajendra Reddy 37f7b880f5
Some checks are pending
Klc-Learner-Frontend / Deploying code in Server (push) Waiting to run
Klc-Learner-Frontend / Build and Test PR (push) Has been skipped
Add .gitea/workflows/deploy.yml
2026-04-10 14:22:29 +00:00

88 lines
2.9 KiB
YAML

name: Klc-Learner-Frontend
on:
push:
branches:
- beta
- testing
- client
- staging
- production
pull_request:
branches:
- main
- beta
- testing
- client
- staging
- production
jobs:
Klc-Learner-Build-Test:
name: Build and Test PR
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Installing Dependecies
run: npm i
- name: Check Build
run: npm run build
- name: Auditing Node Dependecies
run: npm audit --audit-level=critical
KLC-Deployment:
name: Deploying code in Server
if: github.event_name == 'push'
runs-on: ubuntu-latest
env:
ENV_FILE: {{vars.ENV_FILE}}
steps:
- name: Checkout Code in Runner
uses: actions/checkout@v3
- name: Determining 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-learner" >> $GITHUB_ENV
;;
client)
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,ENV_FILE
script: |
set -e
cd $PROJECT_FOLDER
git fetch
git reset --hard origin/$BRANCH_NAME
git stash && git stash clear
git pull origin $BRANCH_NAME
echo "Node Module Installation "
npm i
echo "Writing env"
echo "$ENV_FILE" > .env
echo "Building..."
npm run build