Skip to content

beian

beian #14

name: Deploy to server
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 10
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Restore cache
uses: actions/cache@v4
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Build
run: pnpm run build
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
with:
# 本地.ssh文件下的私钥id_rsa,存在secrets的PRIVATE_KEY中
SSH_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
# 复制操作的参数。"-avzr --delete"意味部署时清空服务器目标目录下的文件
ARGS: "-avz --delete"
# 源目录
SOURCE: "./"
# 部署目标主机
REMOTE_HOST: ${{ secrets.HOST }}
# 部署目标主机端口
REMOTE_PORT: ${{ secrets.PORT }}
# 登录用户
REMOTE_USER: ${{ secrets.USER }}
# 部署目标目录
TARGET: ${{ secrets.TARGET }}
EXCLUDE: "/node_modules/"