Update Submodules #375
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 | |
| on: | |
| push: | |
| branches: | |
| - master | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| update-submodules: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node 22 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install latest npm (>= 11.5.1) | |
| run: | | |
| [ "$(printf '%s\n' "11.5.1" "$(npm -v)" | sort -V | head -n1)" = "11.5.1" ] || npm install -g npm@latest | |
| shell: bash | |
| - name: Update submodules to remote HEAD | |
| run: | | |
| git submodule sync --recursive | |
| git submodule update --init --recursive --remote | |
| - name: Check if there are changes | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "chore: update submodules to latest" | |
| else | |
| echo "No changes to commit." | |
| fi | |
| - name: Push changes | |
| if: always() | |
| run: | | |
| if [ -n "$(git log -1 --pretty=%B | grep 'chore: update submodules')" ]; then | |
| git push origin HEAD:${{ github.ref_name }} | |
| fi |