Skip to content

Commit 238a66a

Browse files
authored
CICD/57 배포 자동화 workflow 구현 (#58)
* cicd: 자동화 배포 workflow 구현 - 기존 도커 이미지 업로드 로직 이후에 deploy 로직을 추가하여 CD workflow 동작시 EC2에 docker-compose 파일을 실행하도록 수정 * style(CD.yml): 마지막 라인 개행 추가 - 잠재적 에러 예방을 위한 개행 추가
1 parent c3f6a22 commit 238a66a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/CD.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: CD Pipeline
2+
13
on:
24
push:
35
branches: [ main ]
@@ -6,6 +8,12 @@ jobs:
68
build-and-push:
79
runs-on: ubuntu-latest
810

11+
services:
12+
redis:
13+
image: redis
14+
ports:
15+
- 6379:6379
16+
917
env:
1018
DB_URL: ${{ secrets.DB_URL }}
1119
DB_USERNAME: ${{ secrets.DB_USERNAME }}
@@ -54,3 +62,23 @@ jobs:
5462
docker build -t 7zrv/somemore:${GITHUB_SHA::7} -t 7zrv/somemore:latest .
5563
docker push 7zrv/somemore:${GITHUB_SHA::7}
5664
docker push 7zrv/somemore:latest
65+
66+
67+
deploy:
68+
runs-on: ubuntu-latest
69+
needs: build-and-push
70+
71+
steps:
72+
- name: SSH 연결을 통한 EC2 배포
73+
uses: appleboy/[email protected]
74+
with:
75+
host: ${{ secrets.EC2_HOST }}
76+
username: ${{ secrets.EC2_USERNAME }}
77+
key: ${{ secrets.EC2_SSH_KEY }}
78+
port: 22
79+
script: |
80+
cd somemore
81+
sudo docker-compose stop
82+
sudo docker-compose rm -f
83+
sudo docker rmi 7zrv/somemore:latest
84+
sudo docker-compose up -d

0 commit comments

Comments
 (0)