Skip to content

Instantly share code, notes, and snippets.

@rexdavinci
Created February 12, 2024 15:24
Show Gist options
  • Save rexdavinci/4c68191265a4bb84ff3e0415e7ff03a2 to your computer and use it in GitHub Desktop.
Save rexdavinci/4c68191265a4bb84ff3e0415e7ff03a2 to your computer and use it in GitHub Desktop.
CI with nodejs and pm2
name: Project CI
on:
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
update_app:
name: Update App And Restart App
runs-on: ubuntu-latest
steps:
- name: install ssh keys and update app
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm i v18
cd ${{ secrets.WORK_DIR }}
git checkout ${{ secrets.MAIN_BRANCH }}
git pull origin && npm i && npm i -g pm2
npx pm2 restart project && exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment