-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (53 loc) · 1.77 KB
/
Copy pathupdate-submodules.yml
File metadata and controls
64 lines (53 loc) · 1.77 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
57
58
59
60
61
62
63
64
name: Update submodules
on:
schedule:
- cron: '0 3 * * FRI'
workflow_dispatch:
inputs:
branches:
description: "Comma-separated branches to update"
required: false
default: "main,Dreaming"
jobs:
update-submodules:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Determine branches
id: vars
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.branches }}" ]; then
echo "branches=${{ inputs.branches }}" >> "$GITHUB_OUTPUT"
else
echo "branches=main,dev" >> "$GITHUB_OUTPUT"
fi
- name: Update submodules on each branch
shell: bash
run: |
set -euo pipefail
IFS=',' read -ra BRANCHES <<< "${{ steps.vars.outputs.branches }}"
for BR in "${BRANCHES[@]}"; do
BR="$(echo "$BR" | xargs)"
echo "Updating branch: $BR"
git fetch origin "$BR":"$BR" || git fetch origin "$BR"
git checkout "$BR"
git submodule sync --recursive
git submodule update --init --recursive
git submodule update --remote --recursive
if ! git diff --quiet; then
git add .
git commit -m "CI: auto-update submodules to latest branches on $BR"
git push origin "$BR"
else
echo "No changes in submodules on $BR"
fi
done