Skip to content

fix : cursor 스키마 수정 (#167) #104

fix : cursor 스키마 수정 (#167)

fix : cursor 스키마 수정 (#167) #104

name: ShowPot-Dev-CD
on:
push:
branches:
- develop
- hotfix/**
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'liberica'
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Copy Secrets
uses: microsoft/variable-substitution@v1
with:
files: |
./app/src/main/resources/application-dev.yml,
./app/src/main/resources/application-cloud-dev.yml,
./app/domain/common-domain/src/main/resources/application-domain-dev.yml
env:
token.secret-key: ${{ secrets.TOKEN_SECRET_KEY }}
cloud.aws.credentials.accessKey: ${{ secrets.AWS_ACCESS_KEY }}
cloud.aws.credentials.secretKey: ${{ secrets.AWS_SECRET_KEY }}
cloud.aws.region: ${{ secrets.AWS_REGION }}
cloud.aws.s3.bucket: ${{ secrets.AWS_BUCKET }}
spring.datasource.url: ${{ secrets.APPLICATION_DATASOURCE_URL_DEV }}
spring.datasource.username: ${{ secrets.APPLICATION_DATASOURCE_USERNAME }}
spring.datasource.password: ${{ secrets.APPLICATION_DATASOURCE_PASSWORD }}
- name: Build with Gradle Wrapper
run: ./gradlew clean build -Dspring.profiles.active=dev
- name: Prepare File for Deployment
run: |
mkdir -p deployment/app/build/libs
cp dockerfile-dev docker-compose-dev.yml deployment/
cp -r ./app/build/libs deployment/app/build
- name: Get Github Actions IP
id: ip
uses: candidob/[email protected]
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
- name: Add Github Actions IP on Security Group
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_DEV_SECURITY_GROUP_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: Upload files to EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_DEV_HOST }}
username: ec2-user
key: ${{ secrets.EC2_DEV_SSH_PRIVATE_KEY }}
source: "deployment/*"
target: "/home/ec2-user/"
- name: Deploy using Docker Compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_DEV_HOST }}
username: ec2-user
key: ${{ secrets.EC2_DEV_SSH_PRIVATE_KEY }}
script: |
cd /home/ec2-user/deployment/
docker-compose -f docker-compose-dev.yml down
docker system prune -f
docker-compose -f docker-compose-dev.yml up -d --build
- name: Remove Github Actions IP from Security Group
if: always()
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_DEV_SECURITY_GROUP_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: Backend CD for Dev Server Discord Notification
uses: sarisia/actions-status-discord@v1
if: success()
with:
title: ✅ 개발 서버 배포 프로세스가 완료되었습니다! ✅
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: "<@1084774841460215839> <@281597829636423682> 배포가 정상적으로 이뤄졌는지 확인해주세요!"
color: 00FF00
username: showPot-Bot
avatar_url: ${{ secrets.DISCORD_NOTIFICATION_SUCCESS_AVATAR_URL }}
- name: Backend CD for Dev Server Discord Notification
uses: sarisia/actions-status-discord@v1
if: failure()
with:
title: ❗️개발 서버 배포 프로세스가 실패했습니다! ❗️
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
color: FF0000
username: showPot-Bot
avatar_url: ${{ secrets.DISCORD_NOTIFICATION_FAILED_AVATAR_URL }}