Skip to content

Secret Message Backend Prod Server CD #9

Secret Message Backend Prod Server CD

Secret Message Backend Prod Server CD #9

name: Secret Message Backend Prod Server CD
on:
workflow_dispatch:
jobs:
build:
name: 빌드
runs-on: ubuntu-22.04
steps:
- name: workflow_dispatch에서 지정한 branch로 checkout
uses: actions/checkout@v3
- name: JDK 17로 설정
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'corretto'
- name: Gradle에 실행 권한 부여
run: chmod +x gradlew
- name: gradle 빌드
run: ./gradlew build
- name: 도커 빌더 생성 및 부팅
uses: docker/setup-buildx-action@v2
- name: 도커 이미지 빌드 및 푸시
uses: docker/build-push-action@v4
with:
file: Dockerfile-prod
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/uni-11th-team5:latest
deploy:
needs: build
name: 배포
runs-on: [ self-hosted, prod ]
steps:
- name: 실행중인 도커 제거
run:
docker stop secret-message && docker rm secret-message && docker rmi -f ${{ secrets.DOCKERHUB_USERNAME }}/uni-11th-team5 || true
- name: 새로 빌드한 도커 실행
run:
docker run -d -p 8080:8080 --name secret-message -e TZ=Asia/Seoul --network host ${{ secrets.DOCKERHUB_USERNAME }}/uni-11th-team5