Skip to content

Instantly share code, notes, and snippets.

@KilianB
Created June 1, 2021 14:13
Show Gist options
  • Save KilianB/6f65b9a0d56eb9228bd0c24e3d646bb2 to your computer and use it in GitHub Desktop.
Save KilianB/6f65b9a0d56eb9228bd0c24e3d646bb2 to your computer and use it in GitHub Desktop.
Deploy Node App
name: CD
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: SSH
uses: appleboy/[email protected]
with:
# ssh host
host: <your server url>
# ssh port
port: <your ssh port if changed>
username: <your username>
# ssh key passphrase
key: ${{ secrets.SSH_SECRET_KEY}}
script: |
cd reponame/
pm2 stop appname
git fetch --all
git reset --hard origin/master
git pull
npm install
cd client/
npm install
cd ../
npm run build
rm -rf src/
pm2 start ecosystem.config.yaml
@KilianB
Copy link
Author

KilianB commented Jun 1, 2021

pm2 stop only works if you do not change the pm2 file itself. Otherwise you would need to delete it. This is a multi repo project.
The git pull part is a bit ugly. You might get away with building it beforehand and not on the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment