Skip to content

cicd: title 길이 수정 #11

cicd: title 길이 수정

cicd: title 길이 수정 #11

#name: Tech-pick Batch-Module CI/CD
#
#on:
# push:
# branches:
# - "aws-deploy-test" # 배포 대상 브랜치
# 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 AWS
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.AWS_BASTION_IP }}
# port: 22
# username: ${{ secrets.AWS_USERNAME }}
# key: ${{ secrets.AWS_ACCESS_KEY }}
# script: |
# echo "Login to Docker Hub for private repository access on bastion..."
# echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
#
# echo "Pulling Docker image on bastion..."
# docker pull ${{ secrets.DOCKERHUB_USERNAME }}/techpick:${{ env.api-version }}-batch-${{ github.sha }}
#
# echo "Tagging Docker image..."
# docker tag minkyeki/techpick:${{ env.api-version }}-batch-${{ github.sha }} techpick:${{ env.api-version }}-batch-staging
#
# echo "Saving Docker image as a tar file..."
# docker save -o /home/ubuntu/techpick-${{ env.api-version }}-batch.tar techpick:${{ env.api-version }}-batch-staging
#
# echo "Copying Docker image to target server..."
# scp -i /home/ubuntu/Techpick-Private.pem -T /home/ubuntu/techpick-${{ env.api-version }}-batch.tar ubuntu@${{ secrets.API_SERVER_PRIVATE_IP }}:/home/ubuntu/
#
# # SSH into target server to load and run the Docker image
# ssh -i /home/ubuntu/Techpick-Private.pem ubuntu@${{ secrets.API_SERVER_PRIVATE_IP }} <<'EOF'
# echo "Loading Docker image on target server..."
# docker load -i /home/ubuntu/techpick-${{ env.api-version }}-batch.tar
#
# echo "Setting up environment variables..."
# cd /home/ubuntu
# rm -rf .env
# touch .env
# echo "DOCKER_MYSQL_USERNAME=${{ secrets.DOCKER_MYSQL_USERNAME }}" >> .env
#
# cd /home/ubuntu
# 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 "Restarting techpick-batch service..."
# docker-compose stop techpick-batch
# docker-compose rm -f techpick-batch
# docker-compose up -d techpick-batch
#
# echo "Cleanup: Removing image and tar file on target server..."
# rm /home/ubuntu/techpick-v2-batch.tar
# docker image prune -af
#
# echo "Removing tar file on target server..."
# rm /home/ubuntu/techpick-v2-batch.tar
# EOF
#
# echo "Cleanup: Removing image and tar file on bastion..."
# rm /home/ubuntu/techpick-v2-batch.tar
# docker image prune -af
#
# - 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: "AWS 배포가 완료되었습니다."
# color: 0xff91a4
# url: "https://github.com/sarisia/actions-status-discord"
# username: GitHub Actions