Skip to content

Commit b71f6be

Browse files
authored
�RINGUS-21 feat: ec2 배포 워크플로 작성
main branch push 시에 ec2 배포
1 parent 35782ae commit b71f6be

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/ci-cd.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI/CD Workflow for EC2 Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- main # main 브랜치에 푸시될 때 실행
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# 1.코드 체크아웃
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
# 2. EC2로 코드 복사 및 스크립트 실행
18+
- name: Deploy to EC2
19+
uses: appleboy/[email protected]
20+
with:
21+
host: ${{ secrets.EC2_HOST }}
22+
username: ${{ secrets.EC2_USER }}
23+
key: ${{ secrets.EC2_SSH_KEY }}
24+
script: |
25+
echo "[GitHub Actions] Starting deployment on EC2"
26+
27+
# 레포지토리 클론 또는 Pull
28+
if [ -d "/home/ubuntu/ring-us-server" ]; then
29+
echo "[GitHub Actions] Pulling latest code"
30+
cd /home/ubuntu/ring-us-server && git pull origin main
31+
else
32+
echo "[GitHub Actions] Cloning repository"
33+
git clone [email protected]:Ring-Us/ring-us-server.git /home/ubuntu/ring-us-server
34+
cd /home/ubuntu/ring-us-server
35+
fi
36+
37+
# 권한 설정 (dev.sh 실행 가능하도록, 추후에 deploy.sh와 분리)
38+
chmod +x dev.sh
39+
40+
# 스크립트 실행 (환경 변수 로드, 빌드, 배포 포함)
41+
./dev.sh

0 commit comments

Comments
 (0)