Skip to content

Commit

Permalink
Merge pull request #631 from woowacourse-teams/hotfix/s3
Browse files Browse the repository at this point in the history
[BE] workflow 수정
  • Loading branch information
kpeel5839 authored Nov 23, 2023
2 parents d148aed + def841a commit 9fe9cbd
Showing 1 changed file with 21 additions and 30 deletions.
51 changes: 21 additions & 30 deletions .github/workflows/be-merge-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ name: Backend production CI/CD

on:
workflow_dispatch:

pull_request:
branches: [ main ]
types: [ closed ]
paths: backend/**

permissions:
contents: read

jobs:
build-and-upload:
build-and-upload:
if: github.event.pull_request.merged

runs-on: ubuntu-22.04

steps:
Expand All @@ -41,39 +41,30 @@ jobs:
run: ./gradlew clean build
working-directory: backend

- name: Docker buildx 설치
uses: docker/[email protected]

- name: Docker Hub 로그인
uses: docker/[email protected]
- name: jar 파일 artifact에 업로드
uses: actions/upload-artifact@v3
with:
username: ${{ secrets.DOCKERHUB_DEV_USERNAME }}
password: ${{ secrets.DOCKERHUB_DEV_TOKEN }}

- name: Docker Image Build
working-directory: backend
run: docker build --platform linux/arm64/v8 -t mapbefine/mapbefine -f Dockerfile-prod .

- name: Docker Hub Push
run: docker push mapbefine/mapbefine
name: BackendApplication
path: backend/build/libs/mapbefine.jar

deploy:
if: github.event.pull_request.merged

runs-on: [ self-hosted, prod ]
needs: build-and-upload


if: github.event.pull_request.merged

steps:
- name: 최신 Docker Image 가져오기
run: |
sudo docker login --username ${{ secrets.DOCKERHUB_DEV_USERNAME }} --password ${{ secrets.DOCKERHUB_DEV_TOKEN }}
sudo docker pull mapbefine/mapbefine:latest
- name: 구버전 jar 파일 삭제
run: rm -rf /home/ubuntu/backend/build/*.jar

- name: Docker Compose
run: |
cd /home/ubuntu/backend
sudo sh zero-downtime-deploy.sh
sudo docker image prune -af
- name: jar파일 artifact에서 다운로드
uses: actions/download-artifact@v3
with:
name: BackendApplication
path: /home/ubuntu/backend/build/

- name: 배포하기
run: /home/ubuntu/backend/deploy.sh

- name: 슬랙 메시지 보내기

Expand Down

0 comments on commit 9fe9cbd

Please sign in to comment.