Github Actions
를 통해 서버와 연결하여 git을 통해 파일을 받고 배포하는 형식
- 프로젝트 Repository에 secret 값이 저장되어 있다.
main
branch 에 push
작용이 일어날 때마다 배포한다.
name: autoDeploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PWD }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ${{ secrets.SSH_REPOSITORY }}
git fetch --all
git reset --hard origin/main
cd ./client
npm install
rm -rf build
npm run build
nginx -s reload
cd ../server
npm install
rm -rf build
npx tsc
pm2 kill
pm2 start ./build/app.js --node-args="-r ./tsconfig-paths-bootstrap.js"