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
21 changes: 17 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ name: Deploy to EC2
on:
workflow_run:
workflows: ["Build and Push to Docker Hub"]
types:
- completed
types: [completed]
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
environment: Pinhouse_env
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
if: >
${{
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
}}

steps:
- name: Deploy to EC2 via SSH
Expand All @@ -23,14 +26,24 @@ jobs:
script: |
set -e

# (선택) 네트워크 체크 - Docker Hub 접근 확인
curl -I https://registry-1.docker.io/v2/ --max-time 8

# Docker Hub 로그인
echo "${{ secrets.DOCKER_ACCESS_TOKEN }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

# 이미지 pull 및 컨테이너 재시작
# 최신 이미지 pull
docker pull ${{ secrets.DOCKER_USERNAME }}/pinhouse:latest

# 기존 컨테이너 정리
docker rm -f pinhouse || true

# 실행
docker run -d \
--name pinhouse \
--restart unless-stopped \
-p 3000:3000 \
${{ secrets.DOCKER_USERNAME }}/pinhouse:latest

# 상태 확인(선택)
docker ps --filter "name=pinhouse"
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

# ✅ 멀티플랫폼(arm64) 빌드용 에뮬레이터
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# 2 Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -33,11 +37,13 @@ jobs:
context: .
file: ./Docker-pinhouse-file
push: true
# ✅ 핵심: 멀티 플랫폼 manifest 생성
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKER_USERNAME }}/pinhouse:latest
${{ secrets.DOCKER_USERNAME }}/pinhouse:${{ github.sha }}
build-args: |
NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}
NEXT_PUBLIC_OAUTH2=${{ secrets.NEXT_PUBLIC_OAUTH2 }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max