Update gradle.yml #42
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: Java CI with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: 저장소 Checkout | |
uses: actions/checkout@v3 | |
- name: 스프링부트 애플리케이션 빌드 # (1) | |
run: ./gradlew build | |
- name: 도커 이미지 빌드 # (2) | |
run: docker build -t 326eunjin/isa-zip . | |
- name: Docker Hub 로그인 # (3) | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Docker Hub 퍼블리시 # (4) | |
run: docker push 326eunjin/isa-zip | |
- name: WAS 인스턴스 접속 및 애플리케이션 실행 # (5) | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
password: ${{ secrets.EC2_KEY }} | |
script: | | |
docker stop $(docker ps -a -f "name=isa-zip" -q) | |
docker rm $(docker ps -a -f "name=isa-zip" -q) | |
docker pull 326eunjin/isa-zip | |
docker run -d -p 8080:8080 326eunjin/isa-zip --env-file ./.env |