-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #631 from woowacourse-teams/hotfix/s3
[BE] workflow 수정
- Loading branch information
Showing
1 changed file
with
21 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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: 슬랙 메시지 보내기 | ||
|
||
|