File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy to EC2
2+
3+ on :
4+ push :
5+ branches :
6+ - main # main 브랜치에 푸시될 때 트리거됨
7+
8+ jobs :
9+ deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout code
14+ uses : actions/checkout@v3
15+
16+ - name : Set up SSH key
17+ run : |
18+ # GitHub secrets에 저장된 PEM 파일을 생성
19+ echo "${{ secrets.EC2_SSH_PEM }}" > ~/.ssh/ec2.pem
20+ chmod 600 ~/.ssh/ec2.pem # SSH 키에 적절한 권한 부여
21+ # EC2 인스턴스의 호스트 키를 확인하지 않도록 설정 (보안을 강화하려면 이 부분을 수정)
22+ echo -e "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
23+
24+ - name : Deploy to EC2
25+ run : |
26+ ssh -i ~/.ssh/ec2.pem ec2-user@YOUR_EC2_PUBLIC_IP << 'EOF'
27+ cd /path/to/your/project
28+ git pull origin main # GitHub에서 최신 변경 사항을 pull
29+ npm install # 필요에 따라 의존성 설치
30+ npm run build
31+ pm2 restart dist/app.js # 서버 재시작 (pm2 또는 다른 방법으로)
32+ EOF
You can’t perform that action at this time.
0 commit comments