-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (112 loc) · 3.09 KB
/
Copy pathci.yml
File metadata and controls
130 lines (112 loc) · 3.09 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: CI/CD Pipeline for Employee Management
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
formatting:
name: 🔧 Install, Lint & Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install root deps
run: npm ci
- name: Run Prettier
run: npm run format
backend:
name: 🚀 Backend JUnit Tests
runs-on: ubuntu-latest
needs: formatting
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: '17'
- name: Run Maven tests
working-directory: backend
run: mvn --batch-mode test
- name: Archive test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: junit-reports
path: backend/target/surefire-reports/*.xml
frontend:
name: 🌐 Frontend Tests
runs-on: ubuntu-latest
needs: formatting
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install & Test Frontend
working-directory: frontend
run: |
npm ci
npm test
docker:
name: 🐳 Build & Push Docker Images
runs-on: ubuntu-latest
needs:
- backend
- frontend
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & push backend image
uses: docker/build-push-action@v3
with:
context: ./backend
file: ./backend/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/employee-management-backend:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/employee-management-backend:latest
- name: Build & push frontend image
uses: docker/build-push-action@v3
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/employee-management-frontend:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/employee-management-frontend:latest
deploy:
name: 🌐 Deploying
runs-on: ubuntu-latest
needs: docker
steps:
- name: Announce Deployment
run: |
echo "✅ Deployed backend to Render"
echo "✅ Deployed frontend to Vercel"
complete:
name: 🎉 All Done
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Final status
run: echo "✅ CI/CD pipeline finished successfully."