From 5fc07f149c803ab1302e85fc617f6bb5f354328b Mon Sep 17 00:00:00 2001 From: Taegeun Kwack Date: Fri, 28 Jun 2024 20:50:17 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20CI=20yml=20Docker=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EB=B9=8C=EB=93=9C=20=EC=98=A4=EB=A5=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 59 +++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 41a0dfd..3814fe5 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,45 +1,56 @@ -name: rhkr8521 CI +name: rhkr8521 - CI on: push: branches: [ "develop" ] + pull_request: + branches: [ "develop" ] -jobs: - build: - runs-on: ubuntu-22.04 +permissions: + contents: read - steps: - - name: checkout +jobs: + # Spring Boot application build and Docker image push process + build-docker-image: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout uses: actions/checkout@v3 - + + # 1. Set up JDK 17 - name: Set up JDK 17 uses: actions/setup-java@v3 with: - distribution: 'corretto' java-version: '17' - - - name: create application.yml + distribution: 'corretto' + + # 2. Create application.yml file + - name: Create application.yml run: | - ## create application.yml mkdir -p ./ChargeControlBackend/src/main/resources - echo "${{ secrets.CI_APPLICATION }}" > ./ChargeControlBackend/src/main/resources/application.yml - - - name: build + echo "${{ secrets.APPLICATION_YML }}" > ./ChargeControlBackend/src/main/resources/application.yml + cat ./ChargeControlBackend/src/main/resources/application.yml + shell: bash + + # 3. Build Spring Boot application + - name: Build with Gradle run: | chmod +x ./ChargeControlBackend/gradlew - ./ChargeControlBackend/gradlew build --project-dir ./ChargeControlBackend -x test + ./ChargeControlBackend/gradlew clean bootJar --project-dir ./ChargeControlBackend shell: bash - - - name: docker image build - run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/chargecontrol_backend . - # Dockerfile과 빌드 컨텍스트가 모두 루트 디렉토리에 있도록 설정 - working-directory: ./ - - - name: docker login + + # 4. Build Docker image + - name: Docker image build + run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/chargecontrol_backend ./ChargeControlBackend + + # 5. DockerHub login + - name: Docker login uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: docker Hub push + + # 6. Push Docker image to DockerHub + - name: Docker Hub push run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/chargecontrol_backend