Skip to content

Build Image 🏗️ and Deploy to VPS 🚀 #4

Build Image 🏗️ and Deploy to VPS 🚀

Build Image 🏗️ and Deploy to VPS 🚀 #4

name: Build 🏗️ and Deploy 🚀 to VPS
on:
workflow_dispatch:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: "npm"
- run: npm install
- run: npm run build --if-present
- uses: actions/upload-artifact@v4
with:
name: app-build
path: dist
deploy:
runs-on: ubuntu-latest
name: Deploy to VPS
needs: build
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: app-build
- run: ls dist
- name: Checkout
uses: actions/checkout@v4
- name: Deploy to VPS
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
echo "Deploying to VPS..."
rm -rf ~/sourcedepth.com/dist
cp -r dist ~/sourcedepth.com/
echo "Deployment complete!"