Skip to content

Instantly share code, notes, and snippets.

@mcnaveen
Created April 30, 2023 03:22
Show Gist options
  • Save mcnaveen/5362750eea18edc15108010d4260fb49 to your computer and use it in GitHub Desktop.
Save mcnaveen/5362750eea18edc15108010d4260fb49 to your computer and use it in GitHub Desktop.
On New Tag create, copy the source to the server, build and restart pm2 service
name: Deploy Next.js Site via SSH
on:
push:
tags:
- "*"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: "18.x"
- name: Install dependencies
run: npm install
- name: Copy files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
source: .
target: /var/www/your-website/
- name: Connect to server and build site
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
script: |
cd /var/www/your-website/
yarn install
yarn build
pm2 restart 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment