Skip to content

Commit cb76600

Browse files
committed
fix: deploy
1 parent 033f99b commit cb76600

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,24 @@ on:
66
- master
77

88
jobs:
9-
deploy:
9+
build-and-deploy:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- name: Deploy via SSH
13+
- uses: actions/checkout@v4
14+
15+
- name: Docker Hub 로그인
16+
uses: docker/login-action@v3
17+
with:
18+
username: ${{ secrets.DOCKER_USERNAME }}
19+
password: ${{ secrets.DOCKER_PASSWORD }}
20+
21+
- name: 이미지 빌드 & Push
22+
run: |
23+
docker build -t ${{ secrets.DOCKER_USERNAME }}/nutrishare:latest .
24+
docker push ${{ secrets.DOCKER_USERNAME }}/nutrishare:latest
25+
26+
- name: EC2 배포
1427
uses: appleboy/ssh-action@v1.0.3
1528
with:
1629
host: ${{ secrets.EC2_HOST }}
@@ -19,5 +32,8 @@ jobs:
1932
script: |
2033
cd ~/Spring
2134
git pull origin master
22-
docker-compose up --build -d
35+
echo "DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}" > .env.tmp
36+
cat .env >> .env.tmp && mv .env.tmp .env
37+
docker pull ${{ secrets.DOCKER_USERNAME }}/nutrishare:latest
38+
docker-compose up -d
2339
docker-compose ps

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ services:
2727
retries: 5
2828

2929
app:
30-
build: .
30+
image: ${DOCKER_USERNAME}/nutrishare:latest
3131
ports:
3232
- "8080:8080"
3333
environment:

0 commit comments

Comments
 (0)