Skip to content

Commit

Permalink
Create deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
aengzu authored Dec 17, 2024
1 parent 121a449 commit 28e9811
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI/CD Pipeline

on:
push:
branches:
- main # main 브랜치에 푸시될 때 실행

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
# 1. 코드 체크아웃
- name: Checkout Code
uses: actions/checkout@v3

# 2. Docker 이미지 빌드
- name: Build Docker Image
run: |
docker build -t backend_server .
# 3. 서버에 코드 및 이미지 전송
- name: Deploy to EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
source: "./*"
target: "/home/ubuntu/backend"

# 4. 서버에서 Docker Compose 실행
- name: SSH into EC2 and restart Docker Compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd /home/ubuntu/backend
docker-compose down
docker-compose up -d --build

0 comments on commit 28e9811

Please sign in to comment.