diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f25f907..cad3460 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -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 @@ -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" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1064413..441d1ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -33,6 +37,8 @@ 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 }} @@ -40,4 +46,4 @@ jobs: 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 \ No newline at end of file