Skip to content

Commit 3be952b

Browse files
authored
Create main.yml
1 parent 31e03ce commit 3be952b

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

.github/workflows/main.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: 同步源码
2+
3+
on:
4+
schedule:
5+
- cron: '0 */6 * * *' # 每6小时运行一次
6+
workflow_dispatch: # 允许手动触发
7+
8+
permissions:
9+
contents: write
10+
actions: write
11+
12+
jobs:
13+
sync:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Configure Git
23+
run: |
24+
git config --global user.name 'GitHub Actions'
25+
git config --global user.email 'actions@github.com'
26+
27+
- name: Add upstream repository
28+
run: |
29+
git remote add upstream ${{ vars.UPSTREAM_REPO }}
30+
31+
- name: Fetch upstream
32+
run: |
33+
git fetch upstream
34+
35+
- name: Update README files
36+
run: |
37+
NOTICE="# 重要通知
38+
39+
开源强化版bolt.new 支持第三方线上及本地几乎所有的API【bolt.diy】
40+
41+
## 视频教程
42+
- 安装教程:https://www.bilibili.com/video/BV1xHCgYDET4/
43+
- 使用教程:https://www.bilibili.com/video/BV1SSCJYpEYm/
44+
- YouTube:https://youtu.be/EIAM20LJods
45+
46+
## 更多资源
47+
更多视频教程请访问:https://github.com/aigem/videos
48+
49+
---
50+
51+
"
52+
53+
# 只检查 README.md 文件
54+
if [ -f "README.md" ] && ! grep -q "开源强化版bolt.new" "README.md"; then
55+
# 创建临时文件并确保正确的顺序
56+
echo "$NOTICE" > temp_readme
57+
cat README.md >> temp_readme
58+
# 使用 cat 直接覆盖原文件
59+
cat temp_readme > README.md
60+
rm temp_readme
61+
62+
echo "Updated README.md"
63+
git add README.md
64+
git commit -m "docs: add notification to README.md"
65+
else
66+
echo "README.md already contains notification or does not exist"
67+
fi
68+
69+
- name: Merge upstream
70+
run: |
71+
git merge upstream/$(git branch --show-current) --no-edit
72+
73+
- name: Remove .tool-versions file
74+
run: |
75+
if [ -f ".tool-versions" ]; then
76+
rm .tool-versions
77+
git add .tool-versions
78+
git commit -m "chore: remove .tool-versions file"
79+
fi
80+
81+
- name: Push changes
82+
run: |
83+
git push origin $(git branch --show-current)

0 commit comments

Comments
 (0)