File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 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+ 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
You can’t perform that action at this time.
0 commit comments