(fix) actuator/prometheus 권한 해제 #157
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/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - develop | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| build-and-push: | |
| name: Build JAR & Publish Docker Image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Build with Gradle (skip tests) | |
| run: ./gradlew build -x test --no-daemon | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build & Push Docker image | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/onair:latest | |
| deploy: | |
| name: Deploy to Server via SSH | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' | |
| steps: | |
| - name: SSH Deploy (docker-compose pull & up) | |
| uses: appleboy/ssh-action@v0.1.8 | |
| with: | |
| host: ${{ secrets.DEPLOY_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.DEPLOY_KEY }} | |
| script: | | |
| cd /home/ubuntu/onAir/src/main/resources # 배포 디렉토리 | |
| docker compose stop spring || true # 컨테이너 중지 | |
| docker compose rm -f spring # 제거 | |
| docker compose pull spring # 레지스트리에서 최신 이미지 가져오기 | |
| docker compose up -d --build spring # 이미지 빌드(또는 pull된 이미지 사용) 후 기동 |