fix: 상담,등록 학교학년 추가 #16
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: Java CI/CD with Gradle | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'corretto' | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew build -x test | |
| - name: Copy JAR to EC2 | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_KEY }} | |
| source: "build/libs/*.jar" | |
| target: "/home/ec2-user" | |
| strip_components: 2 | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_KEY }} | |
| script: | | |
| sudo fuser -k 8080/tcp || true | |
| # 환경변수를 실행 시점에 직접 주입하여 배포 | |
| nohup java -jar \ | |
| -Dspring.profiles.active=prod \ | |
| -DDB_URL_PROD="${{ secrets.DB_URL_PROD }}" \ | |
| -DDB_USERNAME_PROD="${{ secrets.DB_USERNAME_PROD }}" \ | |
| -DDB_PASSWORD_PROD="${{ secrets.DB_PASSWORD_PROD }}" \ | |
| -DJWT_SECRET="${{ secrets.JWT_SECRET }}" \ | |
| -DSOLAPI_API_KEY="${{ secrets.SOLAPI_API_KEY }}" \ | |
| -DSOLAPI_API_SECRET="${{ secrets.SOLAPI_API_SECRET }}" \ | |
| -DSOLAPI_SENDER_NUMBER="${{ secrets.SOLAPI_SENDER_NUMBER }}" \ | |
| /home/ec2-user/*.jar > /home/ec2-user/app.log 2>&1 & |