Skip to content

Sync OpenClash_Overwrite Submodule #641

Sync OpenClash_Overwrite Submodule

Sync OpenClash_Overwrite Submodule #641

name: Sync OpenClash_Overwrite Submodule
on:
schedule:
# 每 2 小时自动检查并同步一次上游最新 Commit
- cron: "0 */2 * * *"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: main-writers
jobs:
sync-submodule:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: main
fetch-depth: 0
submodules: true
- name: Update submodule
run: |
submodule_paths=(
"overwrite/OpenClash_Overwrite"
)
# .gitmodules 中跟踪 main,同步后会指向最新提交
git submodule update --init --remote --checkout "${submodule_paths[@]}"
- name: Commit and push if needed
run: |
submodule_paths=(
"overwrite/OpenClash_Overwrite"
)
if [ -n "$(git status --porcelain -- "${submodule_paths[@]}")" ]; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -- "${submodule_paths[@]}"
git commit -m "chore(overwrite): sync OpenClash_Overwrite submodule"
# 使用 pull --rebase 防止多人同时 push 导致的冲突
git pull --rebase origin main
git push origin HEAD:main
else
echo "No changes to commit."
fi