Skip to content

Commit

Permalink
fix: fix CD script (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
yu-yj215 authored Nov 7, 2024
1 parent f4c82e4 commit 265e199
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "kr-standard" # 리전 설정
run: |
# AWS CLI 설치 확인 및 설정
sudo apt-get update && sudo apt-get install -y awscli
aws configure set aws_access_key_id "${{ secrets.AWS_ACCESS_KEY_ID }}"
aws configure set aws_secret_access_key "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
aws configure set default.region "kr-standard"
# 빌드된 정적 파일을 오브젝트 스토리지로 업로드
aws --endpoint-url=https://kr.object.ncloudstorage.com s3 sync ./dist s3://ask-it-static/dist --acl public-read
aws --endpoint-url=https://kr.object.ncloudstorage.com s3 sync ./apps/client/dist s3://ask-it-static/dist --acl public-read
# 5. Deploy Code and Start Server
- name: Deploy to Development Server
Expand All @@ -53,20 +51,24 @@ jobs:
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.NCP_SERVER_RSA_PRIVATE_KEY }}
script: |
# 배포 디렉토리로 이동
# NVM 설정 로드
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# 전역 패키지 설치
npm install -g pnpm
npm install -g pm2
# 프로젝트 디렉토리 이동 및 최신 코드 가져오기
cd ~/web07-Ask-It
# 최신 코드로 업데이트
git pull origin main
pnpm install
# 서버 디렉토리로 이동하여 환경 변수 설정
cd apps/server
# 환경 변수 설정
echo "DATABASE_URL=${{ secrets.DEV_DATABASE_URL }}" > .env
pm2 stop ask-it || true # 기존 프로세스 종료, 없으면 무시
pm2 delete ask-it || true # 기존 프로세스 제거, 없으면 무시
pm2 start npm --name "ask-it" -- run start:prod # 새로 시작
# pm2로 기존 프로세스 종료 및 새 프로세스 시작
pm2 stop ask-it || true
pm2 delete ask-it || true
pm2 start pnpm --name "ask-it" -- run start:prod

0 comments on commit 265e199

Please sign in to comment.