Skip to content

Commit

Permalink
fix : deploy 경로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jiji-hoon96 committed Aug 12, 2024
1 parent 8f3696a commit d1fff16
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: Deploy to Docker Hub

on:
push:
branches: [main]

jobs:
deploy:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: Checkout code'
uses: actions/checkout@v3

- name: Set up Docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
Expand All @@ -19,11 +21,27 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run: |
docker build -t jihoonyhoon/snappy:latest .
docker push jihoonyhoon/snappy:latest
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/snappy:latest

deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Copy docker-compose file to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
source: 'docker-compose.yml'
target: '~/app'

- name: Deploy to server
uses: appleboy/ssh-action@master
Expand All @@ -32,5 +50,6 @@ jobs:
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/snappy:latest
cd ~/app
docker-compose pull
docker-compose up -d

0 comments on commit d1fff16

Please sign in to comment.