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
34 changes: 34 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy to EC2

on:
workflow_run:
workflows: ["Build and Push to Docker Hub"]
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' }}

steps:
- name: Deploy to EC2 via SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
set -e

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


43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and Push to Docker Hub

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest
environment: Pinhouse_env

steps:
# 1 소스 체크아웃
- name: Checkout code
uses: actions/checkout@v4

# 2 Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# 3 Docker Hub 로그인
- name: Login to Docker Hub (Access Token)
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

# 4 Frontend (Next.js) 이미지 빌드 & 푸시
- name: Build and push frontend image
uses: docker/build-push-action@v5
with:
context: .
file: ./Docker-pinhouse-file
push: true
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