[Merge] 1학기 요구사항 반영 및 오류 수정 develop -> main #14
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: Production Server CI/CD with Gradle and Docker | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/billilge | |
| jobs: | |
| build-docker-image: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Create Firebase Config Directory | |
| run: | | |
| mkdir -p src/main/resources/firebase | |
| echo "${{ secrets.FIREBASE_SERVICE_KEY }}" | base64 --decode > src/main/resources/firebase/firebaseServiceKey.json | |
| shell: bash | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 | |
| - name: Build with Gradle Wrapper | |
| run: ./gradlew clean build -x test | |
| - name: Set up Docker Buildx | |
| if: github.event_name == 'push' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| if: github.event_name == 'push' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and Push Docker Image | |
| if: github.event_name == 'push' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ env.DOCKER_IMAGE }}:latest | |
| deploy: | |
| needs: build-docker-image | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to CapRover | |
| uses: caprover/deploy-from-github@v1.1.2 | |
| with: | |
| server: ${{ secrets.CAPROVER_SERVER }} | |
| app: ${{ secrets.CAPROVER_PROD_APP_NAME }} | |
| token: ${{ secrets.CAPROVER_PROD_APP_TOKEN }} | |
| image: ${{ env.DOCKER_IMAGE }}:latest |