-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
8 deletions.
There are no files selected for viewing
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
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 | ||
|
@@ -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] | ||
|
@@ -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 |