feat: LLM설명 구체화 #73
This file contains hidden or 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: CI/CD with Gradle, Docker Image & Docker Compose | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-and-push-image: | |
| name: Build & Push Docker Image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Grant execute permission for Gradle | |
| run: chmod +x ./gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew clean bootJar | |
| - name: Build Docker Image | |
| run: docker build -t ${{ secrets.DOCKER_USERNAME }}/fossistant:latest . | |
| - name: Docker Hub Login | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Push Docker Image to Docker Hub | |
| run: docker push ${{ secrets.DOCKER_USERNAME }}/fossistant:latest | |
| deploy-with-compose: | |
| name: Deploy to Azure VM via Docker Compose | |
| runs-on: ubuntu-latest | |
| needs: build-and-push-image | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup SSH private key | |
| run: | | |
| echo "${{ secrets.SSH_KEY }}" > private_key.pem | |
| chmod 600 private_key.pem | |
| - name: Debug SSH connection | |
| run: | | |
| ssh -o StrictHostKeyChecking=no -i private_key.pem \ | |
| ${{ secrets.AZURE_VM_USER }}@${{ secrets.AZURE_VM_HOST }} \ | |
| "echo ✅ SSH 접속 성공!" | |
| - name: Generate .env for Docker Compose | |
| run: | | |
| echo "AZURE_DB_USERNAME=${{ secrets.AZURE_DB_USERNAME }}" >> .env | |
| echo "AZURE_DB_PASSWORD=${{ secrets.AZURE_DB_PASSWORD }}" >> .env | |
| echo "GEMINI_KEY=${{ secrets.GEMINI_KEY }}" >> .env | |
| echo "GITHUB_TOKEN=${{ secrets.HUB_TOKEN }}" >> .env | |
| echo "JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }}" >> .env | |
| echo "JWT_ACCESS_TOKEN_TIME=${{ secrets.JWT_ACCESS_TOKEN_TIME }}" >> .env | |
| echo "JWT_REFRESH_TOKEN_TIME=${{ secrets.JWT_REFRESH_TOKEN_TIME }}" >> .env | |
| echo "GITHUB_CLIENT_ID=${{ secrets.CLIENT_ID }}" >> .env | |
| echo "GITHUB_CLIENT_SECRET=${{ secrets.CLIENT_SECRET }}" >> .env | |
| - name: Upload docker-compose.yml to Azure VM | |
| run: | | |
| scp -i private_key.pem -o StrictHostKeyChecking=no \ | |
| docker-compose.yml \ | |
| ${{ secrets.AZURE_VM_USER }}@${{ secrets.AZURE_VM_HOST }}:/home/ubuntu/fossistant/docker-compose.yml | |
| - name: Upload .env to Azure VM | |
| run: | | |
| scp -i private_key.pem -o StrictHostKeyChecking=no \ | |
| .env \ | |
| ${{ secrets.AZURE_VM_USER }}@${{ secrets.AZURE_VM_HOST }}:/home/ubuntu/fossistant/.env | |
| - name: SSH to Azure VM and Deploy with Compose | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.AZURE_VM_HOST }} | |
| username: ${{ secrets.AZURE_VM_USER }} | |
| key: ${{ secrets.SSH_KEY }} | |
| port: 22 | |
| script: | | |
| set -eux | |
| cd /home/ubuntu/fossistant | |
| echo "🛑 Stopping Redis if running..." | |
| sudo systemctl stop redis-server || true | |
| echo "🧼 Killing anything on port 6379..." | |
| sudo fuser -k 6379/tcp || true | |
| echo "🧼 Removing old containers..." | |
| docker rm -f redis fossistant || true | |
| echo "🧹 Stopping and cleaning old compose stack..." | |
| sudo docker compose down --remove-orphans || true | |
| sudo docker compose rm -f || true | |
| echo "✅ Pulling new image..." | |
| sudo docker compose pull | |
| echo "🚀 Deploying with Compose..." | |
| sudo docker compose up -d --build | |
| echo "🎉 Deployment complete!" | |
| docker ps |