Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions .github/workflows/backend-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ on:
- 'HalfFifty_BE/**'

jobs:
# 1. ํ…Œ์ŠคํŠธ ๋ฐ ๋นŒ๋“œ
test:
name: Test and Build Backend
runs-on: ubuntu-latest

steps:

# 1.1 ์ฝ”๋“œ ์ฒดํฌ์•„์›ƒ
- name: Checkout code
uses: actions/checkout@v3

# 1.2 JDK 17 ์„ค์น˜
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand All @@ -40,39 +44,40 @@ jobs:

deploy:
name: Deploy Backend
needs: test
if: github.ref == 'refs/heads/main'
needs: test # ๋นŒ๋“œ/ํ…Œ์ŠคํŠธ๊ฐ€ ์„ฑ๊ณตํ•ด์•ผ ์‹คํ–‰
if: github.ref == 'refs/heads/main' # main ๋ธŒ๋žœ์น˜์—์„œ๋งŒ ์‹คํ–‰
runs-on: ubuntu-latest

steps:
# 2.1 ์ฝ”๋“œ ์ฒดํฌ์•„์›ƒ
- name: Checkout code
uses: actions/checkout@v3

# 2.2 JDK 17 ์„ค์น˜
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Build Docker Image
working-directory: HalfFifty_BE
run: docker build -t half-fifty:latest .

- name: Deploy to EC2
uses: appleboy/[email protected]
# 2.3 ๋นŒ๋“œ๋œ JAR ํŒŒ์ผ์„ EC2๋กœ ์ „์†ก
- name: Upload JAR to EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_IP }}
username: ${{ secrets.AWS_USER }}
key: ${{ secrets.AWS_KEY }}
script: |
docker stop half-fifty || true
docker rm half-fifty || true
docker run -d -p 80:8080 --name half-fifty half-fifty:latest
source: ./HalfFifty_BE/build/libs/HalfFifty_BE-0.0.1-SNAPSHOT.jar
target: ~/HalfFifty_BE-0.0.1-SNAPSHOT.jar

- name: Verify Container Status
# 2.4 EC2์—์„œ Docker Compose๋กœ ๋ฐฐํฌ ์‹คํ–‰
- name: Deploy to EC2 using Docker Compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_IP }}
username: ${{ secrets.AWS_USER }}
key: ${{ secrets.AWS_KEY }}
script: docker ps | grep half-fifty
script: |
cd ~
docker-compose down || true
docker-compose up -d --build
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class HealthCheck {

@GetMapping("/")
public String health() {
return "server on!";
return "server on!!!";
}
}
Loading