Merge branch 'develop' of https://github.com/HD152521/CooperationCent… #65
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: docker-ci | |
| on: | |
| push: | |
| branches: [ "develop", "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v4 | |
| # ✅ Node.js 환경 설치 (npm-run-all not found 방지) | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| # ✅ npm install 실행 → npm-run-all 포함 모든 dependency 설치 | |
| - name: Install npm dependencies | |
| run: | | |
| if [ -f package.json ]; then | |
| npm install | |
| fi | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| cache: gradle | |
| # Spring Boot build (여기서 JS/CSS bundling이 정상 동작함) | |
| - name: Build Spring Boot JAR | |
| run: ./gradlew clean bootJar --no-daemon | |
| - name: Docker metadata (이미지 태그 자동 생성) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} | |
| tags: | | |
| type=sha,format=short | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=raw,value=latest,enable=${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| - name: Login to DockerHub | |
| if: github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.base_ref == 'main') | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and (conditionally) Push Docker image (Docker Hub) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || | |
| (github.event_name == 'pull_request' && github.base_ref == 'main') }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |