-
Notifications
You must be signed in to change notification settings - Fork 10
115 lines (95 loc) · 3.39 KB
/
ci.yml
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: CI/CD Pipeline
on:
push:
branches:
- main # Trigger deployment only on push to the main branch
pull_request:
branches:
- main # Run checks on PRs, but don't deploy
jobs:
# --- Build Frontend ---
build-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js for frontend
uses: actions/setup-node@v3
with:
node-version: '20' # Specify the Node.js version
- name: Install frontend dependencies
working-directory: ./frontend # Navigate to the frontend folder
run: npm install
- name: Build frontend
working-directory: ./frontend
run: npm run build
- name: Upload frontend artifact
uses: actions/upload-artifact@v4
with:
name: angular-build
path: ./frontend/dist/smetovi/ # Path to Angular build files
# --- Build Backend ---
build-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js for backend
uses: actions/setup-node@v3
with:
node-version: '20' # Specify the Node.js version
- name: Install backend dependencies
working-directory: ./backend # Navigate to the backend folder
run: npm install
- name: Upload backend artifact
uses: actions/upload-artifact@v4
with:
name: backend-artifact
path: ./backend # Upload the backend folder for deployment
# --- Deploy Frontend ---
deploy-frontend:
runs-on: ubuntu-latest
needs: build-frontend # Ensure the frontend build completes before deployment
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: angular-build
path: ./frontend/dist/smetovi/ # Ensure this is your Angular build folder
- name: Deploy frontend to cPanel via FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./frontend/dist/smetovi/ # Deploy the actual files
server-dir: /public_html/ # Upload to the existing public_html folder
port: ${{ secrets.FTP_PORT }}
log-level: verbose
overwrite: true # Overwrite existing files
delete: true # Optional: Delete old files in the directory to avoid conflicts
# --- Deploy Backend ---
deploy-backend:
runs-on: ubuntu-latest
needs: build-backend # Ensure the backend build completes before deployment
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download backend artifact
uses: actions/download-artifact@v4
with:
name: backend-artifact
path: ./backend/ # This should be a directory with a trailing slash
- name: Deploy backend to cPanel via FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./backend/ # Ensure this is a directory with a trailing slash
server-dir: /public_html/backend/ # Adjust the path as necessary
port: ${{ secrets.FTP_PORT }}
log-level: verbose
overwrite: true # Overwrite existing files