Merge pull request #117 from code-zero-to-one/QNRR-428-유수아-운영-서버에서만-g… #87
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Front Test Server (Develop) | |
| on: | |
| push: | |
| branches: | |
| - develop # develop 브랜치에 push가 발생하면 실행 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Setup SSH | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.LIGHTSAIL_SSH_KEY }}" > ~/.ssh/id_ed25519 | |
| chmod 600 ~/.ssh/id_ed25519 | |
| ssh-keyscan -H ${{ secrets.LIGHTSAIL_HOST }} >> ~/.ssh/known_hosts | |
| echo "SSH 설정 완료" | |
| - name: Deploy to server | |
| run: | | |
| ssh -i ~/.ssh/id_ed25519 ${{ secrets.LIGHTSAIL_USER }}@${{ secrets.LIGHTSAIL_HOST }} << EOF | |
| # 용량 확보를 위해 도커 컨테이너, 이미지 먼저 정리 | |
| echo "사용하지 않는 컨테이너, 이미지, 네트워크 정리 중 (볼륨제외)..." | |
| sudo docker system prune -a -f | |
| # 디렉토리 없으면 생성 | |
| if [ ! -d "/home/ubuntu/front/study-platform-client-dev" ]; then | |
| mkdir -p "/home/ubuntu/front/study-platform-client-dev" | |
| echo "디렉토리 생성 완료" | |
| fi | |
| cd ~/front/study-platform-client-dev | |
| # git 저장소 없으면 clone, 있으면 fetch + reset (덮어쓰기) | |
| if [ ! -d ".git" ]; then | |
| git clone git@github.com:code-zero-to-one/study-platform-client.git . | |
| echo "Git clone 완료" | |
| else | |
| git fetch origin | |
| git reset --hard origin/develop | |
| echo "Git fetch & reset 완료" | |
| fi | |
| git fetch origin | |
| git checkout develop | |
| git pull origin develop | |
| echo ".env 파일 생성" | |
| echo "NEXT_PUBLIC_API_BASE_URL=${{ secrets.NEXT_PUBLIC_API_BASE_URL }}" > .env | |
| echo "NEXT_PUBLIC_KAKAO_CLIENT_ID=${{ secrets.NEXT_PUBLIC_KAKAO_CLIENT_ID }}" >> .env | |
| echo "NEXT_PUBLIC_GOOGLE_CLIENT_ID=${{ secrets.NEXT_PUBLIC_GOOGLE_CLIENT_ID }}" >> .env | |
| echo "도커 컴포즈 재시작" | |
| sudo docker stop frontend-dev | |
| sudo docker rm frontend-dev | |
| sudo docker compose -f docker-compose.dev.yml up -d --build | |
| echo "운영 서버 배포 완료" | |
| EOF |