Skip to content

update action

update action #4

name: Update Submodules
on:
schedule:
# 每3小时执行一次
- cron: '0 */6 * * *'
push:
# 当main分支有新的推送时执行
branches:
- main
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
# 确保拉取所有子模块
submodules: 'recursive'
- name: Update Submodules
run: |
git submodule update --remote --recursive
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Check if submodules have changed
SUBMODULES_CHANGED=$(git status --porcelain=v1 2>/dev/null | grep "^ M")
if [ "x$SUBMODULES_CHANGED" != "x" ]; then
# Create a new branch
git checkout -b update-submodules-${{ github.run_id }}
git commit -am "Automatically update submodules"
# Push the branch and create a pull request
git push --set-upstream origin update-submodules-${{ github.run_id }}
gh pr create --title "Auto-update submodules" --body "Automated changes to update submodules" --head update-submodules-${{ github.run_id }} --base main
else
echo "No changes in submodules."
fi