This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Update Submodules to Latest Tag #182
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Submodules to Latest Tag | |
| on: | |
| schedule: | |
| - cron: '32 6 * * *' # Daily at 6:32 AM UTC | |
| workflow_dispatch: | |
| jobs: | |
| update-submodules: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo with submodules | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update all submodules to latest tags | |
| run: | | |
| set -e | |
| updated=false | |
| output="$( | |
| git submodule -q foreach ' | |
| git fetch --tags origin | |
| # Tag closest behind origin/HEAD | |
| tag="$(git describe --tags --abbrev=0 origin/HEAD 2>/dev/null || true)" | |
| # Match only version-like tags | |
| regex="^[vV]?[0-9]+(\.[0-9]+)*$" | |
| cur="$(git describe --tags 2>/dev/null || echo "none")" | |
| if echo "$tag" | grep -qE "^$regex$" && [ "$cur" != "$tag" ] && | |
| printf "%s\n%s" "$cur" "$tag" | sort -VC; then | |
| git switch -dq -- "$tag" | |
| echo "$name: $cur -> $tag" | |
| fi | |
| ' | |
| )" | |
| if [ -n "$output" ]; then | |
| echo "$output" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "Update submodules to latest tags" | |
| git show --raw | |
| git push | |
| else | |
| echo "No submodules updated." | |
| fi |