File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-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
7+
8+ jobs :
9+ deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : GitHub Repository checkout
14+ uses : actions/checkout@v4
15+
16+ - name : EC2 서버에 SSH 접속해서 애플리케이션 배포
17+ 18+ with :
19+ host : ${{ secrets.EC2_HOST }}
20+ username : ${{ secrets.EC2_USERNAME }}
21+ key : ${{ secrets.EC2_PRIVATE_KEY }}
22+
23+ script : |
24+ # 1. 작업 디렉토리로 이동
25+ cd ~/BackEnd
26+
27+ # 2. 최신 코드 받아오기
28+ git reset --hard
29+ git checkout main
30+ git pull origin main
31+
32+ # 3. application.properties 설정
33+ echo "${{ secrets.APPLICATION_DB_PROPERTIES }}" > ./src/main/resources/application-db.properties
34+
35+ # 4. 빌드
36+ ./gradlew clean build
37+
38+ # 5. 기존 컨테이너 중지 및 삭제
39+ docker stop be-server || true
40+ docker rm be-server || true
41+
42+ # 6. 도커 이미지 생성 및 실행
43+ docker build -t be-server .
44+ docker run -d --name be-server -p 8080:8080 be-server
You can’t perform that action at this time.
0 commit comments