Skip to content

Commit

Permalink
Update gradle.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
326eunjin authored Feb 24, 2024
1 parent fabb70a commit 917874b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
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

- name: 스프링부트 애플리케이션 빌드 # (1)
run: ./gradlew build

- name: 도커 이미지 빌드 # (2)
run: docker build -t <docker_hub_username>/<image_name> .
run: docker build -t 326eunjin/isa-zip .

- name: Docker Hub 로그인 # (3)
uses: docker/login-action@v2
Expand All @@ -23,7 +33,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Docker Hub 퍼블리시 # (4)
run: docker push <docker_hub_username>/<image_name>
run: docker push 326eunjin/isa-zip

- name: WAS 인스턴스 접속 및 애플리케이션 실행 # (5)
uses: appleboy/[email protected]
Expand All @@ -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_hub_username>/<image_name>
docker run -d -p 8080:8080 --name <container_name> <docker_hub_username>/<image_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

0 comments on commit 917874b

Please sign in to comment.