-
Notifications
You must be signed in to change notification settings - Fork 676
42 lines (36 loc) · 1.22 KB
/
update_submodule.yaml
File metadata and controls
42 lines (36 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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 "actions-bot@users.noreply.github.com"
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