mirror of
https://github.com/afoim/fuwari.git
synced 2026-01-31 09:03:18 +08:00
Merge branch 'main' into Test
This commit is contained in:
64
.github/workflows/pr.yml
vendored
Normal file
64
.github/workflows/pr.yml
vendored
Normal 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}`
|
||||
});
|
||||
@@ -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>
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "fuwari",
|
||||
"compatibility_date": "2025-08-09",
|
||||
"compatibility_date": "2025-06-04",
|
||||
"pages_build_output_dir": "./dist",
|
||||
"assets": {
|
||||
"directory": "./dist"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user