Merge pull request #45 from HSU-Talky/fix/#44 #19
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 with Gradle | |
| on: | |
| pull_request: | |
| branches: ["main"] | |
| push: | |
| branches: ["dev","main"] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| JAVA_VERSION: '21' | |
| IMAGE: ${{ secrets.DOCKER_USERNAME }}/talky-backend | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Temurin JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: ${{ env.JAVA_VERSION }} | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build JAR | |
| run: ./gradlew bootJar -x test --no-daemon | |
| - name: Upload JAR artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-jar | |
| path: build/libs/*.jar | |
| docker-push: | |
| name: Docker Build & Push | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download JAR artifact # build에서 맏느 아티팩트 다운로드 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: app-jar | |
| path: build/libs | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 # Docker Hub 로그인 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build & Push image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ env.IMAGE }}:latest | |
| ${{ env.IMAGE }}:${{ github.sha }} |