[FIX] 추천 시 비어있는 OG 태그 생략 (#723) #27
Workflow file for this run
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 Api-Module CI/CD | |
on: | |
push: | |
branches: | |
- 'backend-v2' # 배포 대상 브랜치 | |
paths: | |
- '.github/workflow/home-server.api.deploy.yml' | |
- 'backend/techpick-core/**' | |
- 'backend/techpick-security/**' | |
- 'backend/techpick-api/**' | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
database-version: 'v2' | |
server-name: 'server.api' # 주의: 홈 서버의 docker-compose가 위치한 디렉토리 명과 일치해야 합니다. | |
module-name: 'techpick-api' | |
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 ${{ env.module-name }} Module | |
run: | | |
./backend/gradlew -p backend/${{ env.module-name }} clean build -x test | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/techpick:${{ env.server-name }}-${{ github.sha }} backend/${{ env.module-name }} | |
- # 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.server-name }}-${{ 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.server-name }}-${{ github.sha }} | |
echo "docker - changing image name and tag ..." | |
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/techpick:${{ env.server-name }}-${{ github.sha }} techpick:${{ env.server-name }}-staging | |
# **************************************************************** | |
echo "create .env file with github repository's ENV setting ..." | |
# **************************************************************** | |
cd /home/project/techpick/${{ env.server-name }} | |
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.database-version }}" >> .env | |
echo "DOCKER_MYSQL_URL=jdbc:mysql://techpick.infra.service-db/${{ secrets.DOCKER_MYSQL_DATABASE }}_${{ env.database-version }}?createDatabaseIfNotExist=true" >> .env | |
echo "RABBITMQ_HOST"=${{ secrets.RABBITMQ_HOST }} >> .env | |
echo "RABBITMQ_PORT"=${{ secrets.RABBITMQ_PORT }} >> .env | |
echo "RABBITMQ_USERNAME"=${{ secrets.RABBITMQ_USERNAME }} >> .env | |
echo "RABBITMQ_PASSWORD"=${{ secrets.RABBITMQ_PASSWORD }} >> .env | |
echo "RABBITMQ_COOKIE"=${{ secrets.RABBITMQ_ERLANG_COOKIE }} >> .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 | |
docker-compose down | |
docker-compose up -d | |
# **************************************************************** | |
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: 'API SERVER DEPLOY' | |
description: 'API 서버 배포가 완료되었습니다.' | |
color: 0xff91a4 | |
url: 'https://github.com/sarisia/actions-status-discord' | |
username: GitHub Actions |