Skip to content
Merged
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
49 changes: 39 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,61 @@ jobs:
# ๋ฐฐํฌ ๋กœ๊น…
echo "๐Ÿš€ Starting deployment..."
echo "๐Ÿ“ PR: #${{ github.event.pull_request.number }}"
echo "๐Ÿ”„ Commit: ${{ github.sha }}"

# ๋ธŒ๋žœ์น˜๋ณ„ ํ™˜๊ฒฝ ์„ค์ •
if [ "${{ github.event.pull_request.base.ref }}" = "main" ]; then
CONTAINER_NAME="app-prod"
ENV_FILE="app-prod.env"
echo "๐Ÿš€ Deploying to PRODUCTION"
elif [ "${{ github.event.pull_request.base.ref }}" = "develop" ]; then
CONTAINER_NAME="app-dev"
ENV_FILE="app-dev.env"
echo "๐Ÿงช Deploying to DEVELOPMENT"
fi

# ์ฝ”๋“œ ๋ณต์‚ฌ
cp -r . /home/ubuntu/coplan/app/
# ๋ฐฐํฌ ๋””๋ ‰ํ† ๋ฆฌ ์„ค์ •
DEPLOY_DIR="/home/ubuntu/coplan/app"

# rsync๋กœ ํŒŒ์ผ ๋™๊ธฐํ™”
echo "๐Ÿ“‚ Synchronizing files..."
rsync -av \
--exclude='.git' \
--exclude='node_modules' \
--exclude='.next' \
--exclude='.env*' \
--exclude='*.log' \
--delete \
./ ${DEPLOY_DIR}/

# ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ ์ด๋™
cd /home/ubuntu/coplan

# ํ™˜๊ฒฝ๋ณ€์ˆ˜ ํŒŒ์ผ ๋ณต์‚ฌ (์žˆ๋Š” ๊ฒฝ์šฐ๋งŒ)
if [ -f "/home/ubuntu/env/${CONTAINER_NAME}.env" ]; then
if [ -f "/home/ubuntu/env/${ENV_FILE}" ]; then
echo "๐Ÿ“‹ Copying environment variables..."
cp /home/ubuntu/env/${CONTAINER_NAME}.env ./app/.env.production
cp "/home/ubuntu/env/${ENV_FILE}" "${DEPLOY_DIR}/.env.production"
fi

# ๋นŒ๋“œ ๋ฐ ๋ฐฐํฌ
docker compose build $CONTAINER_NAME
docker compose up -d --no-deps --build $CONTAINER_NAME
# Docker ์ด๋ฏธ์ง€ ๋นŒ๋“œ
echo "๐Ÿ”จ Building Docker image..."
docker compose build ${CONTAINER_NAME}

# ์ปจํ…Œ์ด๋„ˆ ๊ต์ฒด (๋ฌด์ค‘๋‹จ ๋ฐฐํฌ)
echo "๐Ÿ”„ Updating container..."
docker compose up -d --no-deps ${CONTAINER_NAME}

# ๊ฐ„๋‹จํ•œ ํ—ฌ์Šค์ฒดํฌ
# ํ—ฌ์Šค์ฒดํฌ
echo "๐Ÿฅ Health check..."
sleep 10
docker ps | grep $CONTAINER_NAME

echo "โœ… Deployment completed!"
if docker ps | grep -q ${CONTAINER_NAME}; then
echo "โœ… Container is running"
docker logs --tail 20 ${CONTAINER_NAME}
else
echo "โŒ Container failed to start"
docker logs ${CONTAINER_NAME}
exit 1
fi

echo "โœ… Deployment completed successfully!"
Loading