Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
#3 항상 배포 가능한 상태를 보장 & 자동 배포 (#128)
Browse files Browse the repository at this point in the history
* util: build & deploy

* fix: deploy를 main 브랜치 병합시에만 하도록 수정
  • Loading branch information
soongjamm authored Sep 1, 2021
1 parent 0f8f5b7 commit a821bc8
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CD

on:
pull_request:
branches:
- 'main'
types: [closed]

env:
PROJECT: blue-delivery

jobs:
merge-PR:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_IP }}
username: ${{ secrets.EC2_SSH_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
envs: env.PROJECT
script: |
cd ${{ env.PROJECT }}
git pull
cd techlab-compose
docker-compose pull
docker-compose up --force-recreate
docker image prune -f
54 changes: 54 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

# workflow가 실행되는 시점 : 모든 브랜치에 대해 push 발생시
on:
push:
branches:
- '*'

# Actions 탭에서 수동 실행 가능
workflow_dispatch:

jobs:
build: # "bukld" 라는 하나의 job
runs-on: ubuntu-latest # runner 타입
steps:
# MySQL 데몬
- name: Setup MySQL
uses: mirromutth/mysql-action@v1.1
with:
host port: 3306
container port: 3306
character set server: 'utf8'
collation server: 'utf8_general_ci'
mysql version: '8.0'
mysql database: 'delivery'
mysql root password: ${{ secrets.MYSQL_ROOT_PASSWORD }}

# 브랜치 체크아웃
- uses: actions/checkout@v2

# Cache workflow의 실행 시간을 개선하기 위해 의존성과 빌드 아웃풋을 캐싱한다.
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Lint & Test 수행
- name: Lint & Run & Unit Test
run: ./gradlew check

# Docker hub login
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_ID }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

# jib을 이용해 애플리케이션을 도커 허브로 배포
- name: Run Jib to deploy Application
run: ./gradlew jib

0 comments on commit a821bc8

Please sign in to comment.