Skip to content

Commit a104d75

Browse files
committed
chore: github actions
1 parent 88ae2dd commit a104d75

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
uses: appleboy/[email protected]
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

0 commit comments

Comments
 (0)