Skip to content

Instantly share code, notes, and snippets.

@StanleyMasinde
Created February 9, 2023 08:55
Show Gist options
  • Save StanleyMasinde/664259220501a8bdfa7b2a162d65e815 to your computer and use it in GitHub Desktop.
Save StanleyMasinde/664259220501a8bdfa7b2a162d65e815 to your computer and use it in GitHub Desktop.
name: Deploy
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
jobs:
production:
runs-on: ubuntu-latest
environment:
name: production
url: https://example.com
steps:
- name: Checkout 🛎
uses: actions/checkout@master
- name: Install dependencies 👨🏻‍💻
run: npm i
- name: Build for production 🏗️
run: npm run build
- name: Setup SSH
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.SSH_PRIV_KEY }}" > ~/.ssh/id_rsa
echo "${{ secrets.SSH_PUB_KEY }}" > ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa.pub
ssh-keyscan -H ${{ secrets.IP }} >> ~/.ssh/known_hosts
- name: copy builds to server
run: |
rsync -vrm .output/* ${{ secrets.USER_IP }}:/var/www/example.com/
ssh ${{ secrets.USER_IP }} "pm2 restart ecosystem.config.js"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment