name: Deploy Frontend
on:
push:
branches: [ "development" ]
paths:
- "<your-application-directory>/**"
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Deploy to DigitalOcean droplet via SSH
uses: appleboy/ssh-action@v0.1.3
with:
host: ${{ secrets.SSH_HOST_FRONTEND }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd your-nextjs-app
ls
git pull
yarn install
yarn build
# Check if PM2 process is running
if pm2 list | grep -q 'frontend'; then
# Reload application to ensure zero downtime
pm2 reload frontend
else
# Start the application with PM2 if not already running
pm2 start yarn --name "frontend" -- start
fi
pm2 list