58 lines
1.4 KiB
YAML
58 lines
1.4 KiB
YAML
name: deploy to server
|
|
|
|
on: push
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10
|
|
- name: Setup node 22
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: '22'
|
|
cache: 'pnpm'
|
|
- name: Cache pnpm store
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.pnpm-store
|
|
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-
|
|
# Nuxt 构建缓存,加快二次构建
|
|
- name: Cache Nuxt build
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .nuxt
|
|
key: ${{ runner.os }}-nuxt-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-nuxt-
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
- name: Build project
|
|
run: pnpm run build
|
|
- name: Upload build output
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: nuxt-output
|
|
path: .output
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
if: github.ref == 'refs/heads/master'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
- name: Download build output
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: nuxt-output
|
|
path: .output
|