Add .gitea/workflows/deploy.yml
This commit is contained in:
87
.gitea/workflows/deploy.yml
Normal file
87
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,87 @@
|
||||
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
|
||||
Reference in New Issue
Block a user