Merge branch 'main' into Test

This commit is contained in:
二叉树树
2025-08-13 14:14:24 +08:00
committed by GitHub
4 changed files with 67 additions and 9 deletions

64
.github/workflows/pr.yml vendored Normal file
View File

@@ -0,0 +1,64 @@
name: PR Preview Deploy
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 1. 拉取 PR 分支代码(支持 fork
- name: Checkout PR branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
# 2. 安装 Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
# 3. 安装依赖
- name: Install dependencies
run: npm install
# 4. 本地构建项目(生成 dist
- name: Build site
run: npm run build
# 5. 安装 Wrangler CLI用于上传 dist
- name: Install Wrangler CLI
run: npm install -g wrangler
# 6. 上传 dist 目录到 Cloudflare Pages
- name: Deploy dist to Cloudflare Pages
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_PROJECT_NAME: ${{ secrets.CLOUDFLARE_PROJECT_NAME }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
BRANCH_NAME=pr-${PR_NUMBER}
wrangler pages deploy ./dist \
--project-name=$CLOUDFLARE_PROJECT_NAME \
--branch=$BRANCH_NAME
# 7. 在 PR 评论区发布预览链接
- name: Comment preview URL on PR
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const project = process.env.CLOUDFLARE_PROJECT_NAME;
const url = `https://${project}--pr-${prNumber}.pages.dev`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `✅ 预览已部署:${url}`
});

View File

@@ -25,7 +25,7 @@ const currentYear = new Date().getFullYear();
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://github.com/afoim/fuwari">已开源</a>
<br>
本站使用
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://www.netlify.com/">Netlify</a> 部署并加速
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://secbit.ai/">Secbit</a> 加速
</div>
</div>

View File

@@ -12,13 +12,6 @@ import { Icon } from "astro-icon/components";
<h1 class="text-2xl font-bold text-black dark:text-white">友链</h1>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<a href="https://www.netlify.com/" target="_blank" class="friend-card">
<div class="flex items-center gap-2">
<img src="https://www.netlify.com/favicon.ico" loading="lazy" class="w-5 h-5 rounded">
<div class="font-bold text-black dark:text-white">Netlify本站 CDN</div>
</div>
<div class="text-sm text-black/50 dark:text-white/50">AWS高速IP全球加速静态部署</div>
</a>
<a href="https://secbit.ai" target="_blank" class="friend-card">
<div class="flex items-center gap-2">
<img src="https://secbit.ai/favicon.ico" loading="lazy" class="w-5 h-5 rounded">

View File

@@ -1,6 +1,7 @@
{
"name": "fuwari",
"compatibility_date": "2025-08-09",
"compatibility_date": "2025-06-04",
"pages_build_output_dir": "./dist",
"assets": {
"directory": "./dist"
}