mirror of
https://github.com/adminlove520/AI-Account-Toolkit.git
synced 2026-05-18 09:36:45 +08:00
61 lines
2.3 KiB
YAML
61 lines
2.3 KiB
YAML
name: Submodule Sync
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 0 * * *' # 每天凌晨运行
|
|
workflow_dispatch: # 支持手动触发
|
|
|
|
jobs:
|
|
sync:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
fetch-depth: 0
|
|
|
|
- name: Update submodules
|
|
run: |
|
|
git submodule init
|
|
# 获取所有子模块路径
|
|
sm_paths=$(git config --file .gitmodules --get-regexp path | awk '{print $2}')
|
|
|
|
echo "### Submodule Sync Report" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Submodule | Status | Action |" >> $GITHUB_STEP_SUMMARY
|
|
echo "|-----------|--------|--------|" >> $GITHUB_STEP_SUMMARY
|
|
|
|
for sm in $sm_paths; do
|
|
echo "--------------------------------------------------"
|
|
echo "Checking submodule: $sm"
|
|
URL=$(git config --file .gitmodules --get "submodule.$sm.url")
|
|
|
|
# 检查远程仓库是否存活
|
|
if curl --output /dev/null --silent --head --fail -L "$URL"; then
|
|
echo "Upstream $URL is healthy. Updating to latest commit..."
|
|
if git submodule update --init --recursive --remote "$sm"; then
|
|
echo "Successfully updated $sm"
|
|
echo "| $sm | ✅ OK | Updated to latest |" >> $GITHUB_STEP_SUMMARY
|
|
else
|
|
echo "::warning:: Failed to update $sm (check branch/ref). Skipping."
|
|
echo "| $sm | ⚠️ WARN | Update failed |" >> $GITHUB_STEP_SUMMARY
|
|
fi
|
|
else
|
|
echo "::error:: Submodule $sm upstream ($URL) is 404 or unreachable!"
|
|
echo "Skipping $sm to avoid build failure. Manual intervention required (fork or flatten)."
|
|
echo "| $sm | ❌ 404 | **Action required** |" >> $GITHUB_STEP_SUMMARY
|
|
fi
|
|
done
|
|
|
|
- name: Commit and push if changed
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add .
|
|
if git diff --staged --quiet; then
|
|
echo "No changes to commit"
|
|
else
|
|
git commit -m "chore: sync submodules [skip ci]"
|
|
git push
|
|
fi
|