Merge pull request #1 from BE-04-JTOON/refactor/multi-module #2
This file contains 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: JToon deployment | |
on: | |
push: | |
branches: [ "main" ] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 배포 버전 추출 | |
run: | | |
VERSION=$(grep -o -E "v[0-9]+\.[0-9]+\.[0-9]+" <<< "${{ github.event.head_commit.message }}") | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Github release 자동생성 | |
uses: action-pack/github-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag: ${{ env.VERSION }} | |
title: JTOON - ${{ env.VERSION }} | |
- name: JDK 17 설정 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
- name: Gradle 캐싱 | |
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: 설정파일 application-prod.yml 생성 | |
run: | | |
cd ./module-application/app-api/src/main/resources | |
touch ./application-prod.yml | |
echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.yml | |
shell: bash | |
- name: Gradle Grant 권한 부여 | |
run: chmod +x gradlew | |
- name: Gradle 빌드 | |
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 | |
with: | |
arguments: build | |
- name: 멀티플랫폼 위한 Docker Buildx 설정 | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker Hub 로그인, 빌드, 푸쉬 | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- run: | | |
cd module-application/app-api | |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPOSITORY }}:latest -f Dockerfile . --platform linux/x86_64 | |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPOSITORY }}:latest | |
docker tag ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPOSITORY }}:latest ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPOSITORY }}:${{ env.VERSION }} | |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPOSITORY }}:${{ env.VERSION }} |