Update Submodules #130
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Submodules | |
on: | |
pull_request: | |
branches: | |
- master | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
update-submodules: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4.2.2 | |
- name: 更新 GeoLite.mmdb 子模块 | |
run: | | |
git submodule update --init --recursive GeoLite.mmdb || true | |
git -C GeoLite.mmdb fetch origin || true | |
git -C GeoLite.mmdb reset --hard origin/download || { echo "无法重置到 'origin/download'"; exit 1; } | |
git config --local user.email "2678885646@qq.com" | |
git config --local user.name "PaperDragon-bot" | |
git add GeoLite.mmdb | |
# 检查是否有更改需要提交 | |
if git diff --cached --exit-code > /dev/null; then | |
echo "没有更改,跳过提交和推送。" | |
else | |
git commit -m "更新 GeoLite.mmdb 子模块到最新的 'download' 分支" &> /dev/null | |
if [[ -n "${{ github.event.pull_request }}" ]]; then | |
git push origin "${{ github.event.pull_request.head.ref }}" | |
else | |
git push origin | |
fi | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |