diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..04edf26 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,40 @@ +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 + + - name: Install Yarn + run: npm install -g yarn + + - 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 }} \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index e9ffa30..4f77f2a 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ + output: 'export', // 启用静态导出 }; export default nextConfig;