Skip to content

refactor/#130 게시글 상세 조회 시 이전, 다음 게시글 정보 추가 (#131) #23

refactor/#130 게시글 상세 조회 시 이전, 다음 게시글 정보 추가 (#131)

refactor/#130 게시글 상세 조회 시 이전, 다음 게시글 정보 추가 (#131) #23

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