Skip to content

test: BoardController Like GET TEST 추가 #48

test: BoardController Like GET TEST 추가

test: BoardController Like GET TEST 추가 #48

Workflow file for this run

name: CI/CD
permissions:
checks: write
pull-requests: write
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
env:
MY_SQL_HOST: ${{secrets.MY_SQL_HOST}}
MY_SQL_NAME: ${{secrets.MY_SQL_USER}}
MY_SQL_PWD: ${{secrets.MY_SQL_PWD}}
FILE_LOCATION: /
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: milkweb
MYSQL_ROOT_PASSWORD: ${{secrets.MY_SQL_PWD}}
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
- run: touch ./src/main/resources/application-oauth.properties
- run: echo "${{ secrets.APPLICATION_OAUTH }}" > ./src/main/resources/application-oauth.properties
- run: cat ./src/main/resources/application-oauth.properties
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
- name: Install MySQL Server
run: sudo apt-get install mysql-server
- name: Test MySQL Connection
run: |
mysql -h ${{secrets.MY_SQL_HOST}} -u root -p${{secrets.MY_SQL_PWD}} -e "SELECT 1;"
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
uses: gradle/gradle-build-action@v2.9.0
with:
arguments: |
clean build
# 테스트 후 Result를 보기위해 Publish Unit Test Results step 추가
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: ${{ always() }} # 테스트가 실패하여도 Report를 보기 위해 `always`로 설정
with:
files: build/test-results/**/*.xml
# 도커 로그인 빌드 후 DockerHub에 이미지 Push
- name: Build And Push Docker Image
run: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PWD }}
docker build -t ${{ secrets.DOCKER_USER }}/milkweb .
docker push ${{ secrets.DOCKER_USER }}/milkweb
# 서버에서 Docker 이미지 실행
- name: EC2 Docker Run
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.EC2_HOST }}
username: ec2-user
key: ${{ secrets.EC2_KEY }}
script: |
docker rm -f $(docker ps -qa)
docker rmi ${{ secrets.DOCKER_USER }}/milkweb
docker pull ${{ secrets.DOCKER_USER }}/milkweb
docker-compose up -d
docker image prune -f