Skip to content

Commit e57469c

Browse files
committed
添加github部署公开仓库工作流
1 parent dd894c2 commit e57469c

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Sync to Theme Repository
2+
3+
on:
4+
workflow_dispatch: # 手动触发
5+
6+
jobs:
7+
sync:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout source repository
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0 # 获取完整的提交历史
15+
16+
- name: Setup Git
17+
run: |
18+
git config --global user.name "GitHub Actions"
19+
git config --global user.email "actions@github.com"
20+
21+
- name: Clean posts directory (keep only markdown.md)
22+
run: |
23+
# 进入posts目录
24+
cd src/content/posts
25+
26+
# 删除除了markdown.md以外的所有文件
27+
find . -type f -name "*.md" ! -name "markdown.md" -delete
28+
29+
# 显示剩余文件
30+
echo "Remaining files in posts directory:"
31+
ls -la
32+
33+
- name: Commit changes if any
34+
run: |
35+
git add .
36+
if git diff --staged --quiet; then
37+
echo "No changes to commit"
38+
else
39+
git commit -m "Clean posts directory for theme sync"
40+
fi
41+
42+
- name: Add target repository as remote
43+
run: |
44+
git remote add theme-repo https://github.com/fishcpy/astro-theme-fishcpy.git
45+
46+
- name: Push to target repository
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: |
50+
# 使用token进行认证推送
51+
git remote set-url theme-repo https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/fishcpy/astro-theme-fishcpy.git
52+
53+
# 推送到目标仓库的main分支
54+
git push theme-repo main --force-with-lease
55+
56+
- name: Summary
57+
run: |
58+
echo "✅ Successfully synced to theme repository"
59+
echo "🗑️ Cleaned posts directory (kept only markdown.md)"
60+
echo "📝 Updated banner.enable to true"
61+
echo "🔄 Pushed with commit history to https://github.com/fishcpy/astro-theme-fishcpy.git"

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const siteConfig: SiteConfig = {
2121
},
2222
theme: AUTO_MODE, // 主题模式: AUTO_MODE(默认), LIGHT_MODE(强制浅色), DARK_MODE(强制深色)
2323
banner: {
24-
enable: false,
24+
enable: true,
2525
type: "video", // 'image' 或 'video',指定banner类型
2626
src: "https://www.fis.ink/wj/video/mc.mp4", // 相对于/src目录的路径。如果以'/'开头则表示相对于/public目录
2727
//背景在src\layouts\Layout.astro中

0 commit comments

Comments
 (0)