Skip to content

Commit f24e877

Browse files
committed
工作流
1 parent 8384819 commit f24e877

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

.github/workflows/sync-to-theme-repo.yml

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,38 @@ jobs:
5151
git commit -m "Clean posts directory and remove workflows for theme sync"
5252
fi
5353
54-
- name: Add target repository as remote
55-
run: |
56-
git remote add theme-repo https://github.com/fishcpy/astro-theme-fishcpy.git
57-
58-
- name: Push to target repository
54+
- name: Check if target repository exists and push
5955
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
6157
run: |
62-
# 使用token进行认证推送
63-
git remote set-url theme-repo https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/fishcpy/astro-theme-fishcpy.git
58+
# 检查是否设置了PAT_TOKEN
59+
if [ -z "$PAT_TOKEN" ]; then
60+
echo "❌ PAT_TOKEN secret not found!"
61+
echo "Please create a Personal Access Token and add it as PAT_TOKEN secret"
62+
echo "Token needs 'repo' permissions to push to the target repository"
63+
exit 1
64+
fi
65+
66+
# 设置目标仓库URL
67+
TARGET_REPO="https://github.com/fishcpy/astro-theme-fishcpy.git"
68+
69+
# 检查目标仓库是否存在
70+
echo "🔍 Checking if target repository exists..."
71+
if curl -s -H "Authorization: token $PAT_TOKEN" \
72+
"https://api.github.com/repos/fishcpy/astro-theme-fishcpy" | grep -q '"name"'; then
73+
echo "✅ Target repository exists"
74+
else
75+
echo "❌ Target repository does not exist!"
76+
echo "Please create the repository: https://github.com/fishcpy/astro-theme-fishcpy"
77+
echo "Or check if the repository name is correct"
78+
exit 1
79+
fi
80+
81+
# 添加远程仓库
82+
git remote add theme-repo https://x-access-token:$PAT_TOKEN@github.com/fishcpy/astro-theme-fishcpy.git
6483
65-
# 推送到目标仓库的main分支
84+
# 推送到目标仓库
85+
echo "🚀 Pushing to target repository..."
6686
git push theme-repo main --force-with-lease
6787
6888
- name: Summary
@@ -71,4 +91,9 @@ jobs:
7191
echo "🗑️ Cleaned posts directory (kept only markdown.md)"
7292
echo "🗑️ Removed all workflow files (.github directory)"
7393
echo "📝 Updated banner.enable to true"
74-
echo "🔄 Pushed with commit history to https://github.com/fishcpy/astro-theme-fishcpy.git"
94+
echo "🔄 Pushed with commit history to https://github.com/fishcpy/astro-theme-fishcpy.git"
95+
echo ""
96+
echo "📋 Setup Instructions (if this was your first run):"
97+
echo "1. Create Personal Access Token: https://github.com/settings/tokens"
98+
echo "2. Add token as PAT_TOKEN secret in repository settings"
99+
echo "3. Ensure target repository exists: https://github.com/fishcpy/astro-theme-fishcpy"

0 commit comments

Comments
 (0)