Skip to content

[Fix] 추천 결과 조회 순위 정렬 보장 #112

[Fix] 추천 결과 조회 순위 정렬 보장

[Fix] 추천 결과 조회 순위 정렬 보장 #112

name: develop Build And Deploy
on:
push:
branches: [ "develop" ]
paths-ignore:
- 'README.md'
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE.md'
- '.github/CODEOWNERS'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKERHUB_USERNAME: yogieat
DOCKERHUB_API_IMAGE_NAME: yogieat-server-api
DOCKERHUB_ADMIN_IMAGE_NAME: yogieat-server-admin
DOCKERHUB_BATCH_IMAGE_NAME: yogieat-server-batch-sync
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: DEV
strategy:
matrix:
java-version: [ "25" ]
distribution: [ "corretto" ]
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java-version }}
distribution: ${{ matrix.distribution }}
- name: Setup Gradle Build
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
# Gradlew 실행 허용
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: Set image tags
id: image-tags
run: |
echo "api_image=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_API_IMAGE_NAME }}:${{ github.sha }}" >> $GITHUB_OUTPUT
echo "admin_image=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_ADMIN_IMAGE_NAME }}:${{ github.sha }}" >> $GITHUB_OUTPUT
echo "batch_image=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_BATCH_IMAGE_NAME }}:${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Resolve deploy targets
id: deploy_targets
run: |
if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
git ls-tree -r --name-only "${{ github.sha }}" > changed-files.txt
else
git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" > changed-files.txt
fi
cat changed-files.txt
scripts/ci/resolve-deploy-targets.sh < changed-files.txt
- name: Build and push images with Jib
if: steps.deploy_targets.outputs.skip_deploy != 'true'
env:
API_IMAGE_FULL_URL: ${{ steps.image-tags.outputs.api_image }}
ADMIN_IMAGE_FULL_URL: ${{ steps.image-tags.outputs.admin_image }}
BATCH_IMAGE_FULL_URL: ${{ steps.image-tags.outputs.batch_image }}
DOCKERHUB_USERNAME: ${{ env.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: ./gradlew ${{ steps.deploy_targets.outputs.jib_tasks }} --parallel --build-cache --no-daemon
# 서버로 docker 관련 파일 전송
- name: Copy docker directory to Server
if: steps.deploy_targets.outputs.skip_deploy != 'true'
uses: burnett01/rsync-deployments@7.0.1
with:
switches: -avzr --delete
remote_host: ${{ secrets.SERVER_HOST }}
remote_user: ${{ secrets.SERVER_USERNAME }}
remote_key: ${{ secrets.SERVER_PRIVATE_KEY }}
path: ./docker
remote_path: /root
- name: Copy deploy script to Server
if: steps.deploy_targets.outputs.skip_deploy != 'true'
uses: burnett01/rsync-deployments@7.0.1
with:
switches: -avzr --delete
remote_host: ${{ secrets.SERVER_HOST }}
remote_user: ${{ secrets.SERVER_USERNAME }}
remote_key: ${{ secrets.SERVER_PRIVATE_KEY }}
path: ./scripts/deploy
remote_path: /root/scripts
# TODO: 서버로 Nginx 설정 파일 전송
# - name: Copy default.conf to Server
# uses: burnett01/rsync-deployments@7.0.1
# with:
# switches: -avzr --delete
# remote_host: ${{ secrets.SERVER_HOST }}
# remote_user: ${{ secrets.SERVER_USERNAME }}
# remote_key: ${{ secrets.SERVER_PRIVATE_KEY }}
# path: ./nginx
# remote_path: /root
- name: Deploy to Instance Server
if: steps.deploy_targets.outputs.skip_deploy != 'true'
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_PRIVATE_KEY }}
script: |
set -euo pipefail
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u "${{ env.DOCKERHUB_USERNAME }}" --password-stdin
echo "Deploying API image: ${{ steps.image-tags.outputs.api_image }}"
echo "Deploying Admin image: ${{ steps.image-tags.outputs.admin_image }}"
echo "Deploying Batch image: ${{ steps.image-tags.outputs.batch_image }}"
cd /root/docker
API_IMAGE_FULL_URL="${{ steps.image-tags.outputs.api_image }}" \
ADMIN_IMAGE_FULL_URL="${{ steps.image-tags.outputs.admin_image }}" \
BATCH_IMAGE_FULL_URL="${{ steps.image-tags.outputs.batch_image }}" \
DOCKERHUB_API_IMAGE_NAME="${{ env.DOCKERHUB_API_IMAGE_NAME }}" \
DOCKERHUB_ADMIN_IMAGE_NAME="${{ env.DOCKERHUB_ADMIN_IMAGE_NAME }}" \
DOCKERHUB_BATCH_IMAGE_NAME="${{ env.DOCKERHUB_BATCH_IMAGE_NAME }}" \
DEPLOY_SCOPE="app" \
DEPLOY_ENV="dev" \
DEPLOY_SERVICES="${{ steps.deploy_targets.outputs.deploy_services }}" \
../scripts/deploy/compose-up.sh
docker image prune -a -f
- name: Discord notification
if: always()
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "🚀 DEV 빌드 및 배포"
description: |
**상태**: ${{ job.status }}
**브랜치**: ${{ github.ref_name }}
**커밋**: ${{ github.sha }}
**커밋 메시지**: ${{ github.event.head_commit.message }}
**API 이미지**: ${{ steps.image-tags.outputs.api_image }}
**ADMIN 이미지**: ${{ steps.image-tags.outputs.admin_image }}
**BATCH 이미지**: ${{ steps.image-tags.outputs.batch_image }}
**배포 서비스**: ${{ steps.deploy_targets.outputs.deploy_services || 'skip' }}
color: ${{ job.status == 'success' && '0x57F287' || '0xED4245' }}
username: GitHub Actions