-
Notifications
You must be signed in to change notification settings - Fork 2
56 lines (50 loc) · 1.69 KB
/
update_submodules.yml
File metadata and controls
56 lines (50 loc) · 1.69 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Update Submodules
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * *'
push:
branches:
- main
jobs:
update-submodules:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Update submodules to their latest default branch
run: |
echo "Updating submodules..."
git submodule foreach --recursive '
git fetch origin
if git rev-parse --verify origin/main > /dev/null 2>&1; then
echo "Switching $name ($path) to origin/main"
git checkout origin/main
elif git rev-parse --verify origin/master > /dev/null 2>&1; then
echo "Switching $name ($path) to origin/master"
git checkout origin/master
else
echo "Could not find main or master branch for $name ($path). Submodule not updated."
fi
'
echo "Submodule update process complete."
- name: Commit and push submodule updates
run: |
git add .
if git diff --staged --quiet; then
echo "No submodule changes to commit."
else
echo "Committing submodule updates..."
git commit -m "ci: Update submodules to latest default branch (main/master)"
echo "Pushing changes..."
git push
fi