-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from kckc0608/kckc0608
[19기_권찬] Github Action을 이용한 CI/CD 배포 미션 제출합니다.
- Loading branch information
Showing
4 changed files
with
239 additions
and
2 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,57 @@ | ||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "kckc0608" ] # 'kckc0608' 브랜치에 push 가 발생하면 이 스크립트가 실행된다. | ||
|
||
# 실행할 동작 | ||
jobs: | ||
build: # build 라는 이름의 job 실행 | ||
runs-on: ubuntu-latest # Github Action의 우분투 가상환경에서 실행 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 # 레포지토리 코드를 Github Action의 우분투 가상환경에 내려받기 | ||
|
||
- name: Set up JDK 17 # 가상환경에 JDK 17 세팅하기 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Build with Gradle # 1. 자바 코드 빌드 | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew bootJar | ||
- name: Build Docker Image # 2. 도커 이미지 만들기 & push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t kckc0608/spring . | ||
docker push kckc0608/spring | ||
# - name: Remote SSH Commands | ||
# uses: fifsky/ssh-action@v0.0.6 | ||
# with: | ||
# host: ${{ secrets.HOST }} | ||
# user: ubuntu | ||
# key: ${{ secrets.KEY }} | ||
# pass: ${{ secrets.PASSPHRASE }} | ||
# port: 22 | ||
# command: | | ||
# sudo docker rm -f $(docker ps -qa) | ||
# sudo docker pull kckc0608/spring | ||
# docker run -d -p 8080:8080 kckc0608/spring | ||
|
||
|
||
- name: Remote SSH & Pull Image & Run Container # 3. 원격 접속 & 이미지 pull & 컨테이너 생성 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.KEY }} | ||
passphrase: ${{ secrets.PASSPHRASE }} | ||
port: 22 | ||
script: | | ||
sudo docker rm -f $(docker ps -qa) | ||
sudo docker pull kckc0608/spring | ||
docker run -d -p 8080:8080 kckc0608/spring |
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
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,7 +1,7 @@ | ||
services: | ||
web: | ||
container_name: spring | ||
build: . | ||
image: kckc0608/spring:v1 | ||
ports: | ||
- "8080:8080" | ||
depends_on: | ||
|
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,3 @@ | ||
FROM nginx | ||
|
||
## 나중에 nginx 설정 파일을 복사 |