[FE] 대기방 로비 id, gameId수정 #37
This file contains 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: Deploy To EC2 # | |
on: | |
push: | |
branches: [ "release" ] | |
env: | |
NODE_ENV: test | |
DB_HOST_TEST: localhost | |
DB_PORT_TEST: 3306 | |
DB_PASSWD_TEST: test | |
DB_NAME_TEST: test_db | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0 | |
env: | |
MYSQL_ROOT_PASSWORD: test | |
MYSQL_DATABASE: test_db | |
MYSQL_ROOT_HOST: '%' # 모든 호스트에서 접근 허용 | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd="mysqladmin ping" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
steps: | |
- name: Github Repository 파일 불러오기 | |
uses: actions/checkout@v4 | |
- name: Node 설치 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: BE 의존성 설치 | |
working-directory: ./BE | |
run: npm ci | |
- name: FE 의존성 설치 | |
working-directory: ./FE | |
run: npm ci | |
- name: .env 파일 만들기 | |
run: | | |
echo '${{ secrets.ENV }}' > .env | |
# - name: BE 테스트 코드 실행 (unit test) | |
# working-directory: ./BE | |
# run: npm run test | |
# - name: BE 테스트 코드 실행2 (e2e test) | |
# working-directory: ./BE | |
# run: npm run test:integration | |
# todo: FE 테스트 코드 실행 2 | |
# - name: FE 테스트 코드 실행 | |
# working-directory: ./FE | |
# run: npm run test | |
- name: BE 빌드 | |
working-directory: ./BE | |
run: npm run build | |
- name: FE 빌드 | |
working-directory: ./FE | |
run: npm run build | |
- name: github-action 컴퓨터에서 압축하기 | |
run: | | |
# BE와 FE 모든 필요 파일들을 함께 압축 | |
tar -czvf project.tar.gz \ | |
BE/dist \ | |
BE/package.json \ | |
BE/package-lock.json \ | |
.env \ | |
FE/dist \ | |
FE/package.json \ | |
FE/package-lock.json \ | |
- name: Rsync로 EC2에 빌드된 파일 전송하기 | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.EC2_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts | |
rsync -avz project.tar.gz \ | |
ubuntu@${{ secrets.EC2_HOST }}:/home/ubuntu/nest-server/tobe/ | |
- name: SSH로 EC2에 접속하기 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_PRIVATE_KEY }} | |
script_stop: true | |
script: | | |
rm -rf /home/ubuntu/nest-server/current | |
mkdir /home/ubuntu/nest-server/current | |
mv /home/ubuntu/nest-server/tobe/project.tar.gz /home/ubuntu/nest-server/current/project.tar.gz | |
cd /home/ubuntu/nest-server/current | |
tar -xvf project.tar.gz | |
cd /home/ubuntu/nest-server/current/BE | |
npm i | |
cd | |
cd /home/ubuntu/nest-server/current/FE | |
npm i | |
npx pm2 delete quiz-ground-was1 quiz-ground-was2 || true | |
cd /home/ubuntu/nest-server/current/BE | |
npx pm2 start ecosystem.config.js | |
# todo: # FrontEnd 배포 | |
# # Frontend 배포 | |
# echo "Deploying Frontend..." | |
# sudo rm -rf /var/www/html/* | |
# sudo cp -r ../FE/dist/* /var/www/html/ |