test: pm2 실행 로그 확인 #50
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: Node.js Dev CI/CD | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: # 수동 실행도 가능하도록 함 | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest # 우분투 최신 버전으로 실행 | |
steps: | |
# Checkout the code | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Deploy to EC2 | |
- name: Deploy to EC2 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.AWS_EC2_HOST }} | |
username: ${{ secrets.AWS_EC2_USER }} | |
key: ${{ secrets.AWS_EC2_KEY }} | |
script: | | |
cd ~ | |
cd back-end | |
npx pm2 stop back-end | |
echo stop server | |
git pull origin main | |
if ! command -v node &> /dev/null; then | |
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - | |
sudo apt install -y nodejs | |
fi | |
if ! command -v npm &> /dev/null; then | |
sudo apt install -y npm | |
fi | |
npm ci | |
npx pm2 start npm --name back-end -- start | |
echo start server |