-
Notifications
You must be signed in to change notification settings - Fork 9
100 lines (82 loc) · 2.51 KB
/
main.yml
File metadata and controls
100 lines (82 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: MERN Stack CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: "npm"
cache-dependency-path: |
server/package.json
client/package.json
# Backend build and test
- name: Install backend dependencies
working-directory: ./server
run: npm install
- name: Run backend tests
working-directory: ./server
run: npm test
env:
CI: true
# Frontend build
- name: Install frontend dependencies
working-directory: ./client
run: npm install
- name: Build frontend
working-directory: ./client
run: npm run build
- name: Verify build succeeded
run: |
echo "✅ Backend dependencies installed successfully"
echo "✅ Backend tests passed successfully"
echo "✅ Frontend built successfully"
## CD
# deploy:
# needs: build
# runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/main'
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Set up Node.js
# uses: actions/setup-node@v3
# with:
# node-version: "18.x"
# cache: "npm"
# cache-dependency-path: |
# server/package.json
# client/package.json
# - name: Install and build
# run: |
# cd server && npm install && cd ..
# cd client && npm install && npm run build && cd ..
# - name: Deploy via SSH
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SERVER_HOST }}
# username: ${{ secrets.SERVER_USERNAME }}
# password: ${{ secrets.SERVER_PASSWORD }}
# script: |
# # Navigate to project directory (adjust path as needed)
# cd ${{ secrets.PROJECT_PATH }}
# # Pull latest changes
# git pull origin main
# # Install dependencies
# cd server && npm install && cd ..
# cd client && npm install && npm run build && cd ..
# # Restart the application (adjust as needed)
# cd server && pm2 restart all || pm2 start server.js