-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (53 loc) · 1.51 KB
/
deploy.yml
File metadata and controls
63 lines (53 loc) · 1.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
name: Deploy Application
on:
push:
branches:
- main
schedule:
- cron: "0 3 * * 1" # Every Monday at 03:00 UTC
jobs:
deploy:
name: Deploy Backend and Frontend
runs-on: self-hosted
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20.11.1"
- name: Install and Build Frontend
working-directory: frontend
env:
VITE_BACKEND_URL: ${{ secrets.VITE_BACKEND_URL }}
run: |
npm install
npm run build
- name: Install and Build Backend
working-directory: backend
env:
MONGODB_URI: ${{ secrets.MONGODB_URI }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
run: |
npm install
npm run build
- name: Deploy Frontend
run: |
rsync -av --delete --exclude='.htaccess' ./frontend/dist/ /var/www/html/yeeter/
- name: Deploy Backend
run: |
pm2 delete "graphql-server" || true
cat <<EOF > ecosystem.config.js
module.exports = {
apps: [{
name: 'graphql-server',
script: './backend/dist/index.js',
env: {
MONGODB_URI: '${{ secrets.MONGODB_URI }}',
JWT_SECRET: '${{ secrets.JWT_SECRET }}',
NODE_ENV: 'production'
}
}]
};
EOF
pm2 start ecosystem.config.js