diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d4d54a9..9dbc69d 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,12 +1,22 @@ -name: Backend CD +name: Java CI with Gradle + on: push: - branches: [main] + 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 @@ -14,7 +24,7 @@ jobs: run: ./gradlew build - name: 도커 이미지 빌드 # (2) - run: docker build -t / . + run: docker build -t 326eunjin/isa-zip . - name: Docker Hub 로그인 # (3) uses: docker/login-action@v2 @@ -23,7 +33,7 @@ jobs: password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Docker Hub 퍼블리시 # (4) - run: docker push / + run: docker push 326eunjin/isa-zip - name: WAS 인스턴스 접속 및 애플리케이션 실행 # (5) uses: appleboy/ssh-action@v0.1.6 @@ -32,7 +42,7 @@ jobs: username: ${{ secrets.EC2_USERNAME }} password: ${{ secrets.EC2_KEY }} script: | - docker stop $(docker ps -a -q) - docker rm $(docker ps -a -q) - docker pull / - docker run -d -p 8080:8080 --name / --env-file ./.env + 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