Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Tonyce/de111beab22c8f277b6c98949ffb3a41 to your computer and use it in GitHub Desktop.
Save Tonyce/de111beab22c8f277b6c98949ffb3a41 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