Skip to content

Update submodules

Update submodules #41

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