[BE] 개발 서버 배포 자동화 쉘 스크립트 작성 #81 #2
Workflow file for this run
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
name: Backend develop CI/CD | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: [ develop ] | |
types: [closed] | |
paths: backend/** | |
permissions: | |
contents: read | |
jobs: | |
build-and-upload: | |
if: github.event.pull_request.merged | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: gradlew 실행 권한 부여 | |
run: chmod +x gradlew | |
working-directory: backend | |
- name: Gradle build 시작 | |
run: ./gradlew clean build | |
working-directory: backend | |
- name: jar 파일 artifact에 업로드 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: BackendApplication | |
path: backend/build/libs/mapbefine.jar | |
deploy: | |
runs-on: self-hosted | |
needs: build-and-upload | |
if: github.event.pull_request.merged | |
steps: | |
- name: 구버전 jar 파일 삭제 | |
run: rm -rf /home/ubuntu/backend/build/*.jar | |
- name: jar파일 artifact에서 다운로드 | |
uses: actions/download-artifact@v3 | |
with: | |
name: BackendApplication | |
path: /home/ubuntu/backend/build/ | |
- name: 배포하기 | |
run: /home/ubuntu/backend/build/deploy.sh | |
- name: 슬랙 메시지 보내기 | |
uses: 8398a7/action-slack@v3 | |
with: | |
mention: 'here' | |
if_mention: always | |
status: ${{ job.status }} | |
fields: workflow,job,commit,message,ref,author,took | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
if: always() |