Skip to content

Commit cf011a6

Browse files
committed
complete alternate approach to pin commit [skip ci]
1 parent 71a6868 commit cf011a6

File tree

1 file changed

+17
-38
lines changed

1 file changed

+17
-38
lines changed

.github/workflows/update-submodules.yml

+17-38
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Update Submodules
22

33
on:
44
schedule:
5-
- cron: '0 0 * * 0'
5+
- cron: '0 0 * * 0' # Weekly schedule at midnight UTC
66
workflow_dispatch:
77

88
jobs:
@@ -21,60 +21,39 @@ jobs:
2121
git config --global user.name 'github-actions[bot]'
2222
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
2323
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
3225
run: |
3326
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
4027
41-
- name: Create or update submodules branch
42-
id: update_submodules
28+
- name: Checkout or create update branch
4329
run: |
44-
git fetch origin
4530
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
6231
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+
6342
- name: Commit and push changes
64-
if: steps.update_submodules.outputs.needs_update == 'true'
43+
if: steps.check_submodule_update.outputs.needs_update == 'true'
6544
run: |
6645
git add .
6746
git commit -m "Update submodules to latest commits"
6847
git push origin update-submodules-branch --force
6948
7049
- 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'
7251
uses: peter-evans/create-pull-request@v5
7352
with:
7453
commit-message: Update submodules
7554
committer: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
7655
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
7756
branch: update-submodules-branch
78-
base: ${{ steps.default_branch.outputs.branch }}
57+
base: main
7958
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

Comments
 (0)