[FEAT] 픽 제목 최대 길이 검증 및 Validation 검증 리팩토링 (#499) #19
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: Tech-pick Batch-Module CI/CD | |
on: | |
push: | |
branches: | |
- "backend-v2" # 배포 대상 브랜치 | |
paths: | |
- 'backend/techpick-core/**' | |
- 'backend/techpick-batch/**' | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
api-version: 'v2' | |
steps: | |
# 저장소 Checkout | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
# Gradle 실행 권한 부여 | |
- name: Grant execute permission to gradlew | |
run: chmod +x ./backend/gradlew | |
# JDK 설치 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
# Spring boot application, Docker image 빌드 | |
- name: Build and Deploy techpick-batch Module | |
run: | | |
echo "Building and deploying techpick-batch..." | |
./backend/gradlew -p backend/techpick-batch clean build -x test | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/techpick:${{ env.api-version }}-batch-${{ github.sha }} backend/techpick-batch | |
- # Docker hub 로그인 | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- # Docker hub 업로드 | |
name: Publish to docker hub | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/techpick:${{ env.api-version }}-batch-${{ github.sha }} | |
- name: Deploy on Test-Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: minlife.me | |
port: 4242 | |
username: root | |
password: ${{ secrets.SSH_TEST_SERVER_KYEU_PASSWORD }} | |
script: | | |
echo "login docker hub for private repository access ..." | |
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
echo "docker - pulling..." | |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/techpick:${{ env.api-version }}-batch-${{ github.sha }} | |
echo "docker - changing image name and tag ..." | |
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/techpick:${{ env.api-version }}-batch-${{ github.sha }} techpick:${{ env.api-version }}-batch-staging | |
cd /home/project/techpick | |
echo "create .env file with github repository's ENV setting ..." | |
cd /home/project/techpick/database | |
rm -rf .env | |
touch .env | |
echo "DOCKER_MYSQL_USERNAME=${{ secrets.DOCKER_MYSQL_USERNAME }}" >> .env | |
echo "DOCKER_MYSQL_PASSWORD=${{ secrets.DOCKER_MYSQL_PASSWORD }}" >> .env | |
cd /home/project/techpick/${{ env.api-version }} | |
rm -rf .env | |
touch .env | |
echo "DOCKER_MYSQL_USERNAME=${{ secrets.DOCKER_MYSQL_USERNAME }}" >> .env | |
echo "DOCKER_MYSQL_PASSWORD=${{ secrets.DOCKER_MYSQL_PASSWORD }}" >> .env | |
echo "DOCKER_MYSQL_DATABASE=${{ secrets.DOCKER_MYSQL_DATABASE }}_${{ env.api-version }}" >> .env | |
echo "DOCKER_MYSQL_URL=jdbc:mysql://techpick-mysql:3306/${{ secrets.DOCKER_MYSQL_DATABASE }}_${{ env.api-version }}?createDatabaseIfNotExist=true" >> .env | |
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env | |
echo "JWT_ISSUER=${{ secrets.JWT_ISSUER }}" >> .env | |
echo "GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }}" >> .env | |
echo "GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }}" >> .env | |
echo "KAKAO_CLIENT_ID=${{ secrets.KAKAO_CLIENT_ID }}" >> .env | |
echo "KAKAO_CLIENT_SECRET=${{ secrets.KAKAO_CLIENT_SECRET }}" >> .env | |
echo "NAVER_CLIENT_ID=${{ secrets.NAVER_CLIENT_ID }}" >> .env | |
echo "NAVER_CLIENT_SECRET=${{ secrets.NAVER_CLIENT_SECRET }}" >> .env | |
echo "TECHPICK_BASE_URL=https://${{ env.api-version }}.${{ secrets.TECHPICK_DOMAIN }}" >> .env | |
docker-compose stop techpick-batch | |
docker-compose rm -f techpick-batch | |
docker-compose up -d techpick-batch | |
echo "docker - pruning images that passed 24h ..." | |
docker image prune -af --filter "until=24h" | |
- name: Discord Webhook Notification | |
uses: sarisia/[email protected] | |
if: always() | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
status: ${{ job.status }} | |
title: "TechPick ${{ env.api-version }} - Batch Deployment Result" | |
description: "배포가 완료되었습니다." | |
color: 0xff91a4 | |
url: "https://github.com/sarisia/actions-status-discord" | |
username: GitHub Actions |