Merge pull request #123 from acmauth/minorChanges #90
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 Deploy with SSH | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: npm install | |
- name: Deploy via SSH | |
uses: appleboy/ssh-action@v1.0.0 | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
password: ${{ secrets.SERVER_SSH_PASS }} | |
port: ${{ secrets.SERVER_SSH_PORT }} # Specify your SSH port if it's not the default (22) | |
script: | | |
export NVM_DIR=~/.nvm | |
source ~/.nvm/nvm.sh | |
npm --help | |
# SSH into the server | |
cd studentcomp | |
# Stop previous application if running | |
pm2 stop studentcompaniongui || true | |
# Pull the latest changes | |
git checkout dev | |
git pull origin dev | |
# Install or update dependencies | |
npm install | |
# Start the Node.js application with a process manager like PM2 | |
pm2 start "npm run dev" --name studentcompaniongui |