feat: cd workflow 작성 #3
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: CI/CD Pipeline | |
on: | |
pull_request: | |
branches: [ dev ] | |
push: | |
branches: [ dev ] | |
jobs: | |
ci: | |
name: CI | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v2 | |
with: | |
version: '9' | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build | |
run: pnpm build | |
cd: | |
name: CD | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- name: connect to server via ssh | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
cd /var/www/harmony | |
git pull | |
pnpm install | |
pnpm build | |
pm2 start apps/server/dist/main.js harmony-api | |