Skip to content

Instantly share code, notes, and snippets.

@mskian
Forked from mcnaveen/actions.yml
Created May 3, 2023 06:33
Show Gist options
  • Save mskian/073ee0bd40b50a5bd06ccb4232bdb3d5 to your computer and use it in GitHub Desktop.
Save mskian/073ee0bd40b50a5bd06ccb4232bdb3d5 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