fix : 날짜에 맞는 감정 기능 추가 #29
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: Deploy to AWS EC2 | |
| on: | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - 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 gradlew | |
| run: chmod +x gradlew | |
| - name: Build JAR | |
| run: ./gradlew clean bootJar -x test | |
| - name: List files (debug) | |
| run: | | |
| echo "Build directory:" | |
| ls -la build/ | |
| echo "Libs directory:" | |
| ls -la build/libs/ | |
| echo "All JAR files:" | |
| find . -name "*.jar" -type f | |
| - name: Create deployment package | |
| run: | | |
| mkdir deploy | |
| # JAR 파일 복사 (모든 가능한 패턴 시도) | |
| JAR_FILE="" | |
| if ls build/libs/*.jar 1> /dev/null 2>&1; then | |
| JAR_FILE=$(ls build/libs/*.jar | head -1) | |
| fi | |
| if [ -z "$JAR_FILE" ]; then | |
| echo "❌ No JAR file found!" | |
| exit 1 | |
| fi | |
| echo "✅ Using JAR file: $JAR_FILE" | |
| cp "$JAR_FILE" deploy/app.jar | |
| # 다른 파일들 복사 | |
| cp docker-compose.yml deploy/ | |
| cp prometheus.yml deploy/ | |
| cp Dockerfile deploy/ | |
| tar -czf deploy.tar.gz deploy/ | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Deploy to EC2 | |
| run: | | |
| BUCKET_NAME=thinkeep-deploy-$(date +%Y%m%d%H%M) | |
| aws s3 mb s3://$BUCKET_NAME | |
| aws s3 cp deploy.tar.gz s3://$BUCKET_NAME/deploy.tar.gz | |
| aws ssm send-command \ | |
| --instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \ | |
| --document-name "AWS-RunShellScript" \ | |
| --parameters 'commands=[ | |
| "cd /home/ubuntu/thinkeep || mkdir -p /home/ubuntu/thinkeep && cd /home/ubuntu/thinkeep", | |
| "sudo docker-compose down || true", | |
| "BUCKET_NAME=thinkeep-deploy-$(date +%Y%m%d%H%M)", | |
| "aws s3 cp s3://$BUCKET_NAME/deploy.tar.gz .", | |
| "tar -xzf deploy.tar.gz", | |
| "cp deploy/* .", | |
| "sudo docker system prune -f", | |
| "sudo docker rmi thinkeep-thinkeep-app:latest || true", | |
| "export DB_URL=\"${{ secrets.DB_URL }}\"", | |
| "export DB_USERNAME=\"${{ secrets.DB_USERNAME }}\"", | |
| "export DB_PASSWORD=\"${{ secrets.DB_PASSWORD }}\"", | |
| "export JWT_SECRET=\"${{ secrets.JWT_SECRET }}\"", | |
| "export OPENAI_KEY=\"${{ secrets.OPENAI_API_KEY }}\"", | |
| "export GRAFANA_PASSWORD=\"${{ secrets.GRAFANA_PASSWORD }}\"", | |
| "sudo docker-compose up -d --build" | |
| ]' \ | |
| --region ${{ secrets.AWS_REGION }} |