Skip to content

Update deploy.yml

Update deploy.yml #24

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest # 构建环境使用 ubuntu
steps:
- name: Checkout code # 将代码拉到虚拟机
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
- name: Install dependencies
run: pnpm install
- name: Build Next.js app
run: pnpm build
- name: Deploy to Custom Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /home/project/blog-web
git pull
/root/.node_modules/bin/pnpm install
/root/.node_modules/bin/pnpm build
/root/.node_modules/bin/pm2 restart blog-web