Skip to content

Commit 6e7667c

Browse files
committed
feat: ci-cd.yml 추가
1 parent 6bba49c commit 6e7667c

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

.github/workflows/ci-cd.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ "test-1" ]
6+
pull_request:
7+
branches: [ "test-1" ]
8+
9+
jobs:
10+
backend:
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
working-directory: backend
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up JDK 21
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: temurin
22+
java-version: 21
23+
- run: chmod +x ./gradlew
24+
- run: ./gradlew clean build -x test
25+
26+
- name: Login to Docker Hub
27+
uses: docker/login-action@v2
28+
with:
29+
username: ${{ secrets.DOCKER_USERNAME }}
30+
password: ${{ secrets.DOCKER_PASSWORD }}
31+
32+
- name: Docker build image (backend)
33+
run: docker build --platform linux/amd64 -t limkanghyun/dev-chat-backend ./backend
34+
- name: Docker push backend image
35+
run: docker push limkanghyun/dev-chat-backend
36+
37+
frontend:
38+
runs-on: ubuntu-latest
39+
defaults:
40+
run:
41+
working-directory: frontend
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Setup Node.js
46+
uses: actions/setup-node@v3
47+
with:
48+
node-version: 22
49+
- run: npm install
50+
- run: CI=false npm run build
51+
- run: npm test -- --passWithNoTests
52+
53+
- name: Login to Docker Hub
54+
uses: docker/login-action@v2
55+
with:
56+
username: ${{ secrets.DOCKER_USERNAME }}
57+
password: ${{ secrets.DOCKER_PASSWORD }}
58+
59+
- name: Docker build image(frontend)
60+
run: docker build --platform linux/amd64 -t limkanghyun/dev-chat-frontend ./frontend
61+
- name: Docker push frontend image
62+
run: docker push limkanghyun/dev-chat-frontend
63+
64+
deploy:
65+
runs-on: ubuntu-latest
66+
needs: [ backend, frontend]
67+
68+
steps:
69+
- name: Deploy to EC2 via SSH
70+
uses: appleboy/ssh-action@v1
71+
with:
72+
host: ${{ secrets.EC2_HOST }}
73+
username: ubuntu
74+
key: ${{ secrets.EC2_PRIVATE_KEY }}
75+
script: |
76+
cd ~/NBE5-7-2-TEAM08
77+
docker-compose pull
78+
docker-compose down
79+
docker-compose up -d --build

0 commit comments

Comments
 (0)