Skip to content

Deploy (#208)

Deploy (#208) #84

Workflow file for this run

name: "CI-CD"
on:
push:
branches:
- main
jobs:
Setup:
name: CI/CD Pipeline
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22.12.0'
- name: Install backend dependencies
run: |
echo "### Installing backend dependencies... ###"
npm ci
working-directory: backend
- name: Install frontend dependencies
run: |
echo "### Installing frontend dependencies... ###"
npm ci
working-directory: frontend
- name: Install tests dependencies
run: |
echo "### Installing test dependencies... ###"
npm ci
working-directory: tests
- name: Seed test database
run: |
echo "### Start seed test database... ###"
npm run seed:test
working-directory: backend
- name: Start backend tests with pm2
run: |
echo "### Starting backend tests with pm2... ###"
pm2 start 2
working-directory: backend
- name: Wait for backend to be ready
run: |
echo "### Waiting for backend to be ready... ###"
while ! nc -z localhost 8010; do
echo "Backend is not ready yet. Retrying in 5 seconds..."
sleep 5
done
- name: Build frontend for tests
run: |
echo "### Build test frontend"
npm run build:test
working-directory: frontend
- name: Start frontend tests with pm2
run: |
echo "### Starting frontend tests with pm2... ###"
pm2 start 3
working-directory: frontend
- name: Wait for frontend to be ready
run: |
echo "### Waiting for frontend to be ready... ###"
while ! nc -z localhost 5183; do
echo "Frontend is not ready yet. Retrying in 5 seconds..."
sleep 5
done
- name: Run tests
run: |
echo "### Start tests... ###"
npx codeceptjs run --steps
working-directory: tests
- name: Stop test processes
run: |
echo "### Stop test pm2 process... ###"
pm2 stop 2 3
- name: Restart backend and frontend
run: |
echo "### Restart backend... ###"
pm2 restart 0
working-directory: backend
- name: Wait for backend to be ready
run: |
echo "### Waiting for backend to be ready... ###"
while ! nc -z localhost 8000; do
echo "Backend is not ready yet. Retrying in 5 seconds..."
sleep 5
done
- name: Restart frontend
run: |
echo "### Restart frontend... ###"
pm2 restart 1
working-directory: frontend
- name: Wait for frontend to be ready
run: |
echo "### Waiting for frontend to be ready... ###"
while ! nc -z localhost 3000; do
echo "Frontend is not ready yet. Retrying in 5 seconds..."
sleep 5
done
- name: Finish♥️♥️♥️
run: |
echo "♥️♥️♥️ Поздравляю тебя милый мой! У тебя все получилось ♥️♥️♥️"