Devops/Git

[Git] Gradle JDK 17์šฉ Github ์›Œํฌํ”Œ๋กœ Github workflow ์ž‘์„ฑ ๋ฐฉ๋ฒ• (Git Actions)

yuri lee 2023. 1. 29. 12:31
๋ฐ˜์‘ํ˜•

Intro 

์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” JDK 17์šฉ Github ์›Œํฌํ”Œ๋กœ Github workflow ์ž‘์„ฑ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ฐธ๊ณ ๋กœ github workflow์— ๋Œ€ํ•ด ๊ถ๊ธˆํ•˜์‹  ๋ถ„ ๊ณ„์‹œ๋ฉด ์ผ์ „์— ์ œ๊ฐ€ ์ž‘์„ฑํ•œ ํฌ์ŠคํŒ… ๊ธ€ ([GitHub Actions] GitHub Actions์ด๋ž€? ๊ตฌ์„ฑ์š”์†Œ ๋ฐ Workflows ํŒŒ์ผ ์˜ˆ์ œ ์‚ดํŽด๋ณด๊ธฐ) ์ฐธ๊ณ  ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค. 

 

 

How to do

SpringBoot + Java Version 17 + Gradle ๊ธฐ์ค€ ์ž‘์„ฑ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. 

# This is a basic workflow to help you get started with Actions

name: api-server

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches:
      - dev

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

#env:
#  PROJECT_NAME: api-server
#  S3_BUCKET_NAME: api-server

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'adopt' # See 'Supported distributions' for available options

      - name: (Release) Get current date
        id: date
        run: echo "::set-output name=date::$(date +'%Y/%m/%d')"

      - name: Grant execute permission for gradlew
        run: chmod +x gradlew
        shell: bash

      - name: Build with Gradle
        run: |
          ./gradlew —version
          ./gradlew :api:build -x test
        shell: bash

 

JDK 17 ๋ฒ„์ „์„ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋ฏ€๋กœ ์•„๋ž˜์™€ ๊ฐ™์ด java-version: 17์„ ๋ช…์‹œํ•ด์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค. 

steps:
  # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
  - uses: actions/checkout@v3
  - name: Set up JDK 17
    uses: actions/setup-java@v3
    with:
      java-version: '17'
      distribution: 'adopt' # See 'Supported distributions' for available options
๋ฐ˜์‘ํ˜•