Skip to content

Commit

Permalink
chore: github workflow를 재설정한다.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarltj committed May 26, 2024
1 parent 972bb7b commit 66cdfe7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: gradle build

on:
pull_request:
branches: [ main ]
branches:
- main
- dev

# 권한 설정
permissions: write-all
Expand All @@ -25,10 +27,6 @@ jobs:
- name: Set up Environment
run: echo "${{ secrets.ENV_PROPERTIES_LOCAL }}" > ./.env

# docker로 Test용 mysql 띄우기
- name: Create Mysql Docker Container
run: sudo docker run -d -p 3306:3306 --env MYSQL_DATABASE="${{ secrets.TEST_DATABASE }}" --env MYSQL_ROOT_PASSWORD="${{ secrets.TEST_DATASOURCE_PASSWORD }}" mysql:8.0.31

# 빌드시 캐시 적용
- name: Cache Gradle Packages
uses: actions/cache@v3
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,12 @@ jobs:
- name: Send env file
uses: appleboy/scp-action@master
with:
username: ${{ secrets.USERNAME }}
host: ${{ secrets.NCP_HOST }}
username: root
host: ${{ secrets.NCP_DEV_IP }}
password: ${{ secrets.NCP_PASSWORD }}
source: "./.env"
target: "/home/ubuntu"

# 도커 MYSQL 이미지 실행
- name: Create Mysql Docker Container
run: sudo docker run -d -p 3306:3306 --env MYSQL_DATABASE="${{ secrets.TEST_DATABASE }}" --env MYSQL_ROOT_PASSWORD="${{ secrets.TEST_DATASOURCE_PASSWORD }}" mysql:8.0.31

# 빌드
- name: Build with Gradle
run: ./gradlew clean bootJar
Expand All @@ -55,8 +51,8 @@ jobs:
- name: Send docker-compose.yml
uses: appleboy/scp-action@master
with:
username: ${{ secrets.USERNAME }}
host: ${{ secrets.NCP_HOST }}
username: root
host: ${{ secrets.NCP_DEV_IP }}
password: ${{ secrets.NCP_PASSWORD }}
port: 22
source: "./.docker/docker-compose.yml"
Expand All @@ -66,8 +62,8 @@ jobs:
- name: Deploy to Dev
uses: appleboy/ssh-action@master
with:
username: ${{ secrets.USERNAME }}
host: ${{ secrets.NCP_HOST }}
username: root
host: ${{ secrets.NCP_DEV_IP }}
password: ${{ secrets.NCP_PASSWORD }}
script: |
sudo cp /home/ubuntu/.docker/docker-compose.yml /home/ubuntu
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,12 @@ jobs:
- name: Send env file
uses: appleboy/scp-action@master
with:
username: ${{ secrets.USERNAME }}
host: ${{ secrets.NCP_PROD_HOST }}
username: root
host: ${{ secrets.NCP_PROD_IP }}
password: ${{ secrets.NCP_PROD_PASSWORD }}
source: "./.env"
target: "/home/ubuntu"

# 도커 MYSQL 이미지 실행
- name: Create Mysql Docker Container
run: sudo docker run -d -p 3306:3306 --env MYSQL_DATABASE="${{ secrets.TEST_DATABASE }}" --env MYSQL_ROOT_PASSWORD="${{ secrets.TEST_DATASOURCE_PASSWORD }}" mysql:8.0.31

# 빌드
- name: Build with Gradle
run: ./gradlew clean bootJar
Expand All @@ -55,19 +51,19 @@ jobs:
- name: Send docker-compose.yml
uses: appleboy/scp-action@master
with:
username: ${{ secrets.USERNAME }}
host: ${{ secrets.NCP_PROD_HOST }}
username: root
host: ${{ secrets.NCP_PROD_IP }}
password: ${{ secrets.NCP_PROD_PASSWORD }}
port: 22
source: "./.docker/docker-compose.yml"
target: "/home/ubuntu/"

# 도커 컴포즈 실행
- name: Deploy to Dev
- name: Deploy to Prod
uses: appleboy/ssh-action@master
with:
username: ${{ secrets.USERNAME }}
host: ${{ secrets.NCP_PROD_HOST }}
username: root
host: ${{ secrets.NCP_PROD_IP }}
password: ${{ secrets.NCP_PROD_PASSWORD }}
script: |
sudo cp /home/ubuntu/.docker/docker-compose.yml /home/ubuntu
Expand Down

0 comments on commit 66cdfe7

Please sign in to comment.