Skip to content

Instantly share code, notes, and snippets.

@GarryOne
Created March 28, 2020 12:14
Show Gist options
  • Save GarryOne/20eb5cf6891905e955aef68d1ed06fb4 to your computer and use it in GitHub Desktop.
Save GarryOne/20eb5cf6891905e955aef68d1ed06fb4 to your computer and use it in GitHub Desktop.
Github workflow for deploying app nodejs app through ssh
name: Node.js CI
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install npm dependencies
run: npm install
- name: Run build task
run: npm run build
- name: store-env
uses: Garryone/store-env@master
env:
PORT: 3000
TCP_PORT: 7070
NODE_ENV: dev
DATABASE_NAME: ests
DATABASE_HOST: localhost
DATABASE_USERNAME: ${{ secrets.DB_USER }}
DATABASE_PASSWORD: ${{ secrets.DB_PASS }}
DATABASE_PORT: 5432
- name: Copy build to Server
uses: GarryOne/ssh-deploy@master
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ARGS: "-avzr --delete"
SOURCE: "/"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }}
- name: Start the server
uses: garygrossgarten/github-action-ssh@release
with:
command: |
cd ${{ secrets.REMOTE_TARGET }} &&
npm run migration:run &&
pm2 delete ESTS 2> /dev/null &&
pm2 --name "ESTS" -f start dist/main.js
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment