Skip to content

自动更新子模块 #525

自动更新子模块

自动更新子模块 #525

name: 自动更新子模块
on:
schedule:
- cron: '0 0 * * *' # 每天UTC时间0:00执行
workflow_dispatch:
jobs:
update-submodules:
runs-on: ubuntu-latest
steps:
- name: 签出仓库
uses: actions/checkout@v6
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: 更新子模块
continue-on-error: true
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git pull
git submodule update --init
git submodule update --remote
changed_submodules=$(git diff --cached --name-only | grep -oP 'src/Submodules/\K[^/]+' | sort -u)
git add .
if git diff --staged --quiet; then
echo "跳过更新:子模块没有变化"
else
if [ -n "$changed_submodules" ]; then
submodule_list=$(echo "$changed_submodules" | sort -u | tr '\n' ',' | sed 's/,$//')
git commit -m "chore: 自动更新子模块$submodule_list"
else
git commit -m "chore: 自动更新子模块"
fi
git push
fi