Skip to content

[chore] setup gradle #8

[chore] setup gradle

[chore] setup gradle #8

Workflow file for this run

name: CD
on:
push:
branches: [ main ]
pull_request:
branches:
- main
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Test scenario tags'
required: false
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: 저장소 Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: "17"
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Gradle Caching
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: 현재 디렉터리에 있는 파일 확인
run: ls
- name: 스프링부트 애플리케이션 빌드
run: |
chmod +x gradlew
sudo ./gradlew build
shell: bash
- name: 도커 이미지 빌드
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest .
- name: Docker Hub 로그인
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Docker Hub 퍼블리시
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
- name: WAS 인스턴스 접속 및 애플리케이션 실행
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_SSH_HOST }}
username: ${{ secrets.AWS_SSH_USERNAME }}
key: ${{ secrets.AWS_SSH_KEY }}
port: ${{ secrets.AWS_SSH_PORT }}
script: |
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
docker run -d -p 8080:8080 --name rebing-wonderful ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest