Skip to content

Commit

Permalink
feat: deploy script를 추가한다.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarltj committed Jul 21, 2024
1 parent f1f8191 commit be1a024
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: deploy to cloud

on:
push:
branches:
- dev
- setting/**

# 권한 설정
permissions:
contents: read

jobs:
CI-CD:
runs-on: ubuntu-latest

steps:
# JDK 설정
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

# 빌드
- name: Build with Gradle
run: ./gradlew clean bootJar

# 빌드 후 도커 허브로 push
- name: Docker Build & Push to Hub
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} -f ./.docker/Dockerfile .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}
# 도커 컴포즈 설정 파일 서버로 전달하기(복사 후 붙여넣기)
- name: Send docker-compose.yml
uses: appleboy/scp-action@master
with:
username: root
host: ${{ secrets.NCP_DEV_IP }}
password: ${{ secrets.NCP_PASSWORD }}
port: 22
source: "./.docker/docker-compose.yml"
target: "/home/ubuntu/"

# 도커 컴포즈 실행
- name: Deploy
uses: appleboy/ssh-action@master
with:
username: root
host: ${{ secrets.NCP_DEV_IP }}
password: ${{ secrets.NCP_PASSWORD }}
script: |
sudo cp /home/ubuntu/.docker/docker-compose.yml /home/ubuntu
cd /home/ubuntu
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}
docker-compose up -d
docker image prune -f

0 comments on commit be1a024

Please sign in to comment.