Skip to content

fix: use dist/ from GitHub Actions instead of rebuilding on VPS #25

fix: use dist/ from GitHub Actions instead of rebuilding on VPS

fix: use dist/ from GitHub Actions instead of rebuilding on VPS #25

Workflow file for this run

name: Deploy to VPS
on:
push:
branches:
- main
- develop
workflow_dispatch: # Cho phép chạy thủ công
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run linter
run: pnpm run lint
continue-on-error: true # Nếu lint fail vẫn tiếp tục
- name: Build application
run: pnpm run build
- name: Deploy to VPS
uses: appleboy/scp-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USERNAME }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT || 22 }}
source: "dist/,package.json,pnpm-lock.yaml"
target: "/home/${{ secrets.VPS_USERNAME }}/elearning-backend"
strip_components: 0
- name: Execute deployment script on VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USERNAME }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT || 22 }}
script: |
cd /home/${{ secrets.VPS_USERNAME }}/elearning-backend
chmod +x deploy.sh
./deploy.sh