Skip to content

Commit 021ffd4

Browse files
committed
Add deploy workflow from main
1 parent d9a2afb commit 021ffd4

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Production Deployment
2+
3+
on:
4+
push:
5+
branches: [ "main" ] # Branch adın 'master' ise burayı değiştir
6+
7+
jobs:
8+
deploy:
9+
runs-on: self-hosted # Sunucundaki runner'ı tetikler
10+
11+
steps:
12+
- name: Checkout Code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '22'
19+
cache: 'npm'
20+
21+
# 1. TÜM BAĞIMLILIKLARI KUR (ROOT)
22+
# package-lock.json root'ta olduğu için kurulumu en dışta yapıyoruz.
23+
- name: Install Dependencies
24+
run: npm ci
25+
26+
# 2. LINT KONTROLLERİ (Hata varsa durur)
27+
# - name: Lint Backend
28+
# working-directory: ./backend
29+
# run: npm run lint
30+
# continue-on-error: false # Hata varsa durdur
31+
32+
### - name: Lint Frontend
33+
# working-directory: ./frontend
34+
# run: npm run lint
35+
# continue-on-error: false
36+
37+
# 3. BUILD İŞLEMLERİ
38+
- name: Build Backend
39+
working-directory: ./backend
40+
run: npm run build
41+
42+
- name: Build Frontend
43+
working-directory: ./frontend
44+
run: npm run build
45+
46+
# 4. DEPLOY (Dosyaları Taşıma)
47+
# Runner _work klasöründe çalışır, biten işi canlı klasörüne taşırız.
48+
- name: Deploy to Production Folder
49+
run: |
50+
echo "Dosyalar taşınıyor..."
51+
# node_modules root'ta olduğu için onu ve app klasörlerini taşıyoruz
52+
rsync -av --exclude '.git' --exclude '.github' --exclude '.env' ./ /root/apps/validatier/
53+
54+
# 5. PM2 RELOAD
55+
- name: Restart PM2
56+
run: |
57+
cd /root/apps/validatier
58+
# Yeni environment değişkenlerini de alması için update-env
59+
pm2 reload ecosystem.config.js --update-env
60+
pm2 save

0 commit comments

Comments
 (0)