Skip to content

refactor/#133 Jacoco 워크플로우 이름 변경 (#134) #24

refactor/#133 Jacoco 워크플로우 이름 변경 (#134)

refactor/#133 Jacoco 워크플로우 이름 변경 (#134) #24

name: Build and Deploy to Dev Server
on:
push:
branches:
- develop
workflow_dispatch:
jobs:
build-docker-image:
runs-on: ubuntu-latest
environment: dev
steps:
- name: get repo from github
uses: actions/checkout@v3
# JDK setting
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# gradle 빌드
- name: Setup Gradle
run: chmod +x gradlew
- name: Build with Gradle Wrapper
run: ./gradlew clean build -p aics-api -x test
# DockerHub 로그인
- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# Docker 이미지 빌드
- name: Docker image build
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:${{ github.sha }} .
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:latest
# Docker Hub 이미지 푸시
- name: docker Hub push
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:${{ github.sha }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-server:latest
deploy-to-dev:
runs-on: ubuntu-latest
needs: build-docker-image
environment: dev
steps:
- name: SSH to server and deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
script: |
echo "${{ secrets.SERVER_PASSWORD }}" | sudo -S docker-compose -f ${{ secrets.DOCKER_COMPOSE_YAML_PATH }} pull
echo "${{ secrets.SERVER_PASSWORD }}" | sudo -S docker-compose -f ${{ secrets.DOCKER_COMPOSE_YAML_PATH }} up -d