51 lines
1.3 KiB
YAML
51 lines
1.3 KiB
YAML
name: Deploy to Cloudflare Pages
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Deploy
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
deployments: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Node.js 22
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: 'yarn' # 自动缓存 yarn 依赖
|
|
|
|
- name: Install Yarn
|
|
run: npm install -g yarn
|
|
|
|
- name: Cache Next.js build
|
|
uses: actions/cache@v3
|
|
id: cache-next-build
|
|
with:
|
|
path: |
|
|
.next/cache
|
|
key: ${{ runner.os }}-next-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-next-
|
|
|
|
- name: Install dependencies with Yarn
|
|
run: yarn install --frozen-lockfile
|
|
|
|
- name: Build project
|
|
run: yarn build
|
|
|
|
- name: Publish to Cloudflare Pages
|
|
uses: cloudflare/pages-action@v1
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
projectName: xiaomubiao # 替换为你的 Cloudflare Pages 项目名
|
|
directory: ./out # Next.js 默认输出目录
|
|
# gitHubToken: ${{ secrets.GITHUB_TOKEN }} |