From e49f0ec484985e2b5613cf1373f71599a7a6a531 Mon Sep 17 00:00:00 2001 From: Daeil Kim <119060046+tls3254@users.noreply.github.com> Date: Sun, 7 Apr 2024 16:56:39 +0900 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 71 +++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a727275..a705743 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,23 +1,62 @@ -name: CI - +name: CI/CD # 1 깃허브 액션 이름 변경 on: push: - branches: - - main + branches: [ main ] + pull_request: + branches: [ main ] + +env: + RESOURCE_PATH: ./src/main/resources/application.yml, # application.yml 설정 파일 jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up JDK 11 - uses: actions/setup-java@v2 + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 17 + - run: touch ./src/main/resources/application.yml # 해당 경로에 파일 생성 + - run: echo "${{ secrets.APPLICATION }}" > ./src/main/resources/application.yml # "${{ secrets.APPLICATION }}" 이 부분을 기존 yml파일의 내용을 삭제하고 추가 + - run: cat ./src/main/resources/application.yml # yml파일 내용 확인 + + # gradle 버전 설정 + - name: Setup Gradle Wrapper + run: gradle wrapper --gradle-version 8.5 + shell: bash + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + + # [2] +# - name: Build with Gradle +# run: ./gradlew clean build +# shell: bash + + # 권한 부여 + - name: Grant execute permission for gradlew + run: chmod +x gradlew - name: Build with Gradle - env: - MY_SECRET_PROPERTY: ${{ secrets.PROPERTIES }} - run: ./gradlew build --info + run: ./gradlew clean build + # run 키워드는 실행할 명령어를 입력 + # ./gradlew clean build에는 그레들을 사용해 프로젝트를 빌드 이전 상태로 돌리고 다시 빌드하는 명령어를 실행 + + # 2 현재시간 가져오기 + - name: Get current time + uses: josStorer/get-current-time@v2.0.2 + id: current-time + with: + format: "YYYY-MM-DDTHH-mm-ss" + utcOffset: "+09:00" + + # 3 배포용 패키지 경로 저장 + - name: Set artifact + run: echo "artifact=$(ls ./build/libs)" >> $GITHUB_ENV + # $GITHUB_ ENV를 사용해 깃허브 워크플로 전체적으로 사용할 수 있는 환경 변수를 설정할 수 있습니다. + shell: bash + + - name: Show artifact + run: echo "Artifact is ${{ env.artifact }}" + shell: bash