#133 [Refactor] 관리자 투표 삭제 배틀 단위로 변경 및 퀴즈/투표 타입 검증 추가 (#134) #54
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: [ "dev" ] # dev 브랜치에 푸시할 때 작동 | |
| workflow_dispatch: # | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: 'gradle' # 캐싱 추가: 빌드 속도가 훨씬 빨라집니다. | |
| - name: Build with Gradle | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew build -x test | |
| - name: Create .env file from Secret | |
| run: | | |
| cat <<'EOF' > .env | |
| ${{ secrets.ENV_VARIABLES }} | |
| EOF | |
| - name: Copy JAR and .env to EC2 | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| # -plain.jar는 배포에 필요 없으므로 제외합니다. | |
| source: "build/libs/*-SNAPSHOT.jar, .env" | |
| target: "~/" | |
| strip_components: 2 | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| fuser -k 8080/tcp || true | |
| chmod +x ~/start.sh | |
| ~/start.sh |