Skip to content

Update Submodules #12737

Update Submodules

Update Submodules #12737

name: Update Submodules
on:
workflow_dispatch:
schedule:
# Run this workflow hourly at *:17 UTC
- cron: "17 * * * *"
jobs:
update-submodules:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update Submodules
run: |
# Initialize all submodules first
git submodule update --init src/pkgs
# Read pinned submodules (if config exists)
PINNED=""
if [ -f .pinned-submodules ]; then
PINNED=$(grep -v '^#' .pinned-submodules | grep -v '^$' || true)
fi
# Update each submodule, skipping pinned ones
for submodule in src/pkgs/*/; do
submodule="${submodule%/}" # Remove trailing slash
if echo "$PINNED" | grep -q "^${submodule}$"; then
echo "Skipping pinned submodule: $submodule"
else
echo "Updating submodule: $submodule"
git submodule update --remote "$submodule"
fi
done
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Check for Changes
id: git-check
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes=changes present" >> $GITHUB_OUTPUT
else
echo "changes=" >> $GITHUB_OUTPUT
fi
- name: Setup SSH
uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
- name: Commit and Push if changes are present
if: steps.git-check.outputs.changes != ''
run: |
git remote set-url origin [email protected]:${{ github.repository }}.git
git add .
git commit -m "Update submodules"
git push