bug: 데이터소스 뎁스 변경 (#761) #228
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 Dev CD | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- dev | |
paths: | |
- backend/** | |
jobs: | |
build: | |
name: 🏗️ Build Jar and Upload Docker Image | |
environment: dev | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: backend | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
token: ${{ secrets.SUBMODULE_GITHUB_TOKEN }} | |
- name: 🏗️ Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'corretto' | |
java-version: 21 | |
- name: 🏗️ Set up Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: 🏗️ Build with Gradle | |
run: ./gradlew clean bootJar | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker Image Build and Push | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./backend | |
push: true | |
tags: ${{ secrets.DOCKER_REPOSITORY_NAME }}:${{ github.sha }} | |
platforms: linux/arm64 | |
deploy: | |
name: 🚀 Server Deployment | |
environment: dev | |
needs: build | |
runs-on: [ self-hosted, develup-dev ] | |
defaults: | |
run: | |
working-directory: backend | |
env: | |
BACKEND_APP_IMAGE_NAME: ${{ secrets.DOCKER_REPOSITORY_NAME }}:${{ github.sha }} | |
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }} | |
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }} | |
MYSQL_ROOT_HOST: ${{ secrets.MYSQL_ROOT_HOST }} | |
HOST_NAME: 'DEV_SERVER' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
token: ${{ secrets.SUBMODULE_GITHUB_TOKEN }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker Compose up | |
run: docker compose -f compose.dev.yml up -d | |
- name: Clean Unused Image | |
run: docker image prune -af | |
slack-notify_success: | |
runs-on: ubuntu-latest | |
environment: dev | |
needs: | |
- build | |
- deploy | |
if: success() | |
steps: | |
- name: Extract Commit Title | |
run: | | |
COMMIT_TITLE=$(echo "${{ github.event.head_commit.message }}" | head -n 1) | |
echo "COMMIT_TITLE=$COMMIT_TITLE" >> $GITHUB_ENV | |
- name: Build and Deploy Success | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.ISSUE_CHANNEL }} | |
payload: | | |
{ | |
"text": "Build and Deploy Status", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "<!channel> \n 📣 Server Build & Deploy 결과를 안내 드립니다. 📣 \n\t • 🚀 Build Success \n\t • 🟢 Deploy Success \n\t • 🏷️ 관련 Commit: <${{ github.event.head_commit.url }}|${{ env.COMMIT_TITLE }}>" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
slack-notify_build-fail: | |
runs-on: ubuntu-latest | |
environment: dev | |
needs: | |
- build | |
if: failure() | |
steps: | |
- name: Extract Commit Title | |
run: | | |
COMMIT_TITLE=$(echo "${{ github.event.head_commit.message }}" | head -n 1) | |
echo "COMMIT_TITLE=$COMMIT_TITLE" >> $GITHUB_ENV | |
- name: Build Fail | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.ISSUE_CHANNEL }} | |
payload: | | |
{ | |
"text": "Build and Deploy Status", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "<!channel> \n 📣 Server Build & Deploy 결과를 안내 드립니다. 📣 \n\t • 🔴 Build Fail \n\t • 🏷️ 관련 Commit: <${{ github.event.head_commit.url }}|${{ env.COMMIT_TITLE }}>" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
slack-notify_deploy-fail: | |
runs-on: ubuntu-latest | |
environment: dev | |
needs: | |
- deploy | |
if: failure() | |
steps: | |
- name: Extract Commit Title | |
run: | | |
COMMIT_TITLE=$(echo "${{ github.event.head_commit.message }}" | head -n 1) | |
echo "COMMIT_TITLE=$COMMIT_TITLE" >> $GITHUB_ENV | |
- name: Deploy Fail | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.ISSUE_CHANNEL }} | |
payload: | | |
{ | |
"text": "Build and Deploy Status", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "<!channel> \n 📣 Server Build & Deploy 결과를 안내 드립니다. 📣 \n\t • 🚀Build Success \n\t • 🔴Deploy Fail \n\t • 🏷️ 관련 Commit: <${{ github.event.head_commit.url }}|${{ env.COMMIT_TITLE }}>" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.BOT_TOKEN }} |