@@ -2,7 +2,7 @@ name: Update Submodules
2
2
3
3
on :
4
4
schedule :
5
- - cron : ' 0 0 * * 0'
5
+ - cron : ' 0 0 * * 0' # Weekly schedule at midnight UTC
6
6
workflow_dispatch :
7
7
8
8
jobs :
@@ -21,60 +21,39 @@ jobs:
21
21
git config --global user.name 'github-actions[bot]'
22
22
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
23
23
24
- - name : Get default branch
25
- id : default_branch
26
- run : echo "::set-output name=branch::$(git rev-parse --abbrev-ref origin/HEAD | sed 's@^origin/@@')"
27
-
28
- - name : Checkout default branch
29
- run : git checkout ${{ steps.default_branch.outputs.branch }}
30
-
31
- - name : Clean up old branches
24
+ - name : Fetch all branches
32
25
run : |
33
26
git fetch --all
34
- for branch in $(git branch -r | grep -v '\->' | grep -v 'origin/HEAD' | grep -v 'origin/master' | sed 's/origin\///'); do
35
- if git show-ref --verify --quiet refs/heads/$branch; then
36
- echo "Deleting local branch: $branch"
37
- git branch -D $branch || true
38
- fi
39
- done
40
27
41
- - name : Create or update submodules branch
42
- id : update_submodules
28
+ - name : Checkout or create update branch
43
29
run : |
44
- git fetch origin
45
30
git checkout -B update-submodules-branch origin/update-submodules-branch || git checkout -b update-submodules-branch
46
- git submodule update --init --remote
47
- echo "Submodule status:"
48
- git submodule status --recursive
49
- echo "Local submodule commits:"
50
- git submodule foreach 'echo $path: $(git rev-parse --short HEAD)'
51
- echo "Remote submodule commits:"
52
- git submodule foreach 'git fetch origin && echo $path: $(git rev-parse HEAD) vs $(git rev-parse @{u})'
53
- echo "Git status:"
54
- git status --porcelain
55
- if [ -n "$(git status --porcelain)" ]; then
56
- echo "Submodule updates found"
57
- echo "::set-output name=needs_update::true"
58
- else
59
- echo "No submodule updates found"
60
- echo "::set-output name=needs_update::false"
61
- fi
62
31
32
+ - name : Update submodules to latest commits
33
+ run : |
34
+ git submodule update --remote --merge
35
+ git submodule status
36
+
37
+ - name : Check for submodule updates
38
+ id : check_submodule_update
39
+ run : |
40
+ git diff --quiet || echo "Submodule updates found" && echo "::set-output name=needs_update::true"
41
+
63
42
- name : Commit and push changes
64
- if : steps.update_submodules .outputs.needs_update == 'true'
43
+ if : steps.check_submodule_update .outputs.needs_update == 'true'
65
44
run : |
66
45
git add .
67
46
git commit -m "Update submodules to latest commits"
68
47
git push origin update-submodules-branch --force
69
48
70
49
- name : Create or update Pull Request
71
- if : steps.update_submodules .outputs.needs_update == 'true'
50
+ if : steps.check_submodule_update .outputs.needs_update == 'true'
72
51
uses : peter-evans/create-pull-request@v5
73
52
with :
74
53
commit-message : Update submodules
75
54
committer : github-actions[bot] <github-actions[bot]@users.noreply.github.com>
76
55
author : github-actions[bot] <github-actions[bot]@users.noreply.github.com>
77
56
branch : update-submodules-branch
78
- base : ${{ steps.default_branch.outputs.branch }}
57
+ base : main
79
58
title : Update Submodules
80
- body : This pull request updates all submodules to their latest commits.
59
+ body : This pull request updates submodules to their latest commits.
0 commit comments