update startNewDefense.js #23
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 VM Instance | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Delete Previous Build | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
port: ${{ secrets.PORT }} | |
script: | | |
rm -rf /home/bot/build/ | |
- name: Copy files to VM | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
port: ${{ secrets.PORT }} | |
source: './src/*, package.json, package-lock.json' # 현재 디렉토리의 파일 및 폴더를 복사 | |
target: '/home/bot/build' # VM 인스턴스의 /home/bot 경로로 복사 | |
- name: Install Dependencies | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd /home/bot/build | |
npm ci | |
cp /home/bot/.env /home/bot/build/.env | |
cp /home/bot/config.json /home/bot/build/config.json | |
npx pm2 delete index | |
npm start | |