Update Submodules #13
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: | |
workflow_dispatch: # allow manual trigger | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "0 0 * * *" # daily update | |
permissions: | |
contents: write # 确保有对仓库内容的写权限 | |
pull-requests: write # 如果涉及拉取请求,也需要相应权限 | |
jobs: | |
update-submodules: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive # update all submoduleswith: | |
fetch-depth: 0 # fetch all history for all tags and branches | |
- name: Update submodules to latest commit | |
run: | | |
git config --global user.name "GitHub Actions Bot" | |
git config --global user.email "[email protected]" | |
git submodule status | |
git submodule update --init --recursive | |
git submodule update --remote --merge | |
if [[ $(git status --porcelain) ]]; then | |
# Check if there are changes | |
echo "Changes detected, committing and pushing..." | |
git add . | |
git commit -m "Update submodules to latest" | |
git push origin main | |
else | |
echo "No changes detected, skipping commit and push." | |
fi |