Skip to content

Merge pull request #94 from ecolink-JOIN/feature/#90-get_joined_study #86

Merge pull request #94 from ecolink-JOIN/feature/#90-get_joined_study

Merge pull request #94 from ecolink-JOIN/feature/#90-get_joined_study #86

Workflow file for this run

name: Deploy to Development Server
on:
push:
branches: [ "develop", "feature/cd/deploy" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Copy Secrets
uses: ./.github/actions/copy_secret
with:
profile: dev
oauth-secret: ${{ secrets.OAUTH_SECRET }}
s3-secret: ${{ secrets.S3_SECRET }}
dev-db-secret: ${{ secrets.DEV_DB_SECRET }}
- name: Run MySQL image for test
run: docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=join_db mysql:8.0.31
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25
with:
arguments: build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
build/libs/*.jar
Dockerfile
docker-compose.yml
- name: Deployment Fail Notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 'Deployment Fail Notification'
text: '서버 배포에 실패했습니다.'
fields: repo,message,commit,author,ref,workflow,job,took,pullRequest
mention: 'U067CTV6REE,U06BYPA2RGR,U081M9VG1SN,U082A3WSLN4'
if_mention: failure
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_BACKEND_WEBHOOK_URL }} # required
if: failure()
deploy:
needs: build
runs-on: ubuntu-latest
env:
APP_PATH: ${{ secrets.APP_PATH }}
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: SCP JAR to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_KEY }}
source: "build/libs/*.jar, ./Dockerfile, ./docker-compose.yml"
target: ${{ env.APP_PATH }}
- name: SSH Execute command on EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_KEY }}
script: |
cd ${{ env.APP_PATH }}
docker compose down --rmi local
docker image prune -f
docker-compose up --build -d
- name: Deployment Success Notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 'Deployment Success Notification'
text: '서버가 성공적으로 배포되었습니다.'
fields: repo,message,commit,author,ref,workflow,job,took,pullRequest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: success()
- name: Deployment Fail Notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 'Deployment Fail Notification'
text: '서버 배포에 실패했습니다.'
fields: repo,message,commit,author,ref,workflow,job,took,pullRequest
mention: 'U067CTV6REE,U06BYPA2RGR,U081M9VG1SN,U082A3WSLN4'
if_mention: failure
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_BACKEND_WEBHOOK_URL }} # required
if: failure()