-
Notifications
You must be signed in to change notification settings - Fork 4
60 lines (50 loc) · 2 KB
/
update-submodules.yml
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
57
58
59
60
name: Update Submodules
on:
schedule:
- cron: '0 0 * * 0' # Weekly schedule at midnight UTC
workflow_dispatch:
jobs:
update_submodules:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Set up Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Fetch all branches
run: git fetch --all
- name: Checkout or create update branch
run: |
git checkout -B update-submodules-branch origin/update-submodules-branch || git checkout -b update-submodules-branch
- name: Update submodules to latest commits
run: |
git submodule update --remote --merge
git status
- name: Check for submodule changes
id: check_submodule_update
run: |
git diff --quiet || echo "Submodule changes detected" && echo "::set-output name=needs_update::true"
- name: Commit submodule changes
if: steps.check_submodule_update.outputs.needs_update == 'true'
run: |
git submodule foreach 'git add .'
git add .
git status
git commit -m "Update submodules to latest commits" || echo "No changes to commit"
git push origin update-submodules-branch --force || true
- name: Create or update Pull Request
if: steps.check_submodule_update.outputs.needs_update == 'true'
uses: peter-evans/create-pull-request@v5
with:
commit-message: Update submodules
committer: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
branch: update-submodules-branch
base: main
title: Update Submodules
body: This pull request updates submodules to their latest commits.