-
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.
특정 브랜치에 Push Event 발생 시 Github Runner VM에 의해 배포 파이프라인이 동작합니다.
- Loading branch information
1 parent
e72442b
commit e19d0d7
Showing
1 changed file
with
51 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Deploy to Develop Environment | ||
|
||
on: | ||
push: | ||
branches: | ||
- feat/#4-CICD | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Java 17 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '17' | ||
|
||
- name: Update Git submodules | ||
run: git submodule update --remote --recursive | ||
|
||
- name: Build and test with Gradle | ||
run: ./gradlew test | ||
|
||
- name: Build and push Docker image | ||
run: | | ||
./gradlew clean bootBuildImage \ | ||
-PDOCKERHUB_ID=${{ secrets.DOCKERHUB_ID }} \ | ||
-PDOCKERHUB_TOKEN=${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: SSH into EC2 instance | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_PRIVATE_KEY }} | ||
port: ${{ secrets.EC2_SSH_PORT }} | ||
|
||
- name: Download Docker image from Docker Hub | ||
run: docker pull mungmnb777/tteokguk:latest | ||
|
||
- name: Stop existing container (if running) | ||
run: docker ps -f name=be-server -q | xargs --no-run-if-empty docker container stop | ||
|
||
- name: Remove existing container (if exists) | ||
run: ocker ps -a -f name=be-server -q | xargs --no-run-if-empty docker container rm | ||
|
||
- name: Run Docker container | ||
run: docker run -d --name be-server -p 80:8080 mungmnb777/tteokguk:latest |