File tree Expand file tree Collapse file tree 7 files changed +67
-0
lines changed
Expand file tree Collapse file tree 7 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Auto Update Submodules
2+
3+ on :
4+ workflow_dispatch :
5+ schedule :
6+ - cron : ' 0 0 * * *' # Runs daily at midnight UTC
7+
8+ jobs :
9+ update-submodules :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout repository
13+ uses : actions/checkout@v2
14+ with :
15+ submodules : true
16+ token : ${{ secrets.GH_PAT }}
17+
18+ - name : Check and update submodules
19+ run : |
20+ git submodule foreach --quiet '
21+ remote_url=$(git remote get-url origin)
22+ branch=$(git rev-parse --abbrev-ref HEAD)
23+ latest_remote_commit=$(git ls-remote $remote_url $branch | awk "{print \$1}")
24+ current_commit=$(git rev-parse HEAD)
25+
26+ if [ "$latest_remote_commit" != "$current_commit" ]; then
27+ echo "Updating submodule $name..."
28+ git fetch origin $branch
29+ git checkout $latest_remote_commit
30+ cd ..
31+ git add $name
32+ else
33+ echo "No updates for submodule $name."
34+ fi
35+ '
36+
37+ - name : Commit and push changes if any
38+ run : |
39+ if git diff --cached --quiet; then
40+ echo "No changes to commit."
41+ exit 0
42+ fi
43+
44+ git config --global user.email "github-actions@github.com"
45+ git config --global user.name "GitHub Actions"
46+ git commit -m "Auto-update submodules with new commits"
47+ git push origin HEAD:main # Change 'main' if your default branch is different
Original file line number Diff line number Diff line change 1+ [submodule "mttnotes "]
2+ path = mttnotes
3+ url = https://github.com/mrtechtroid/mttnotes.git
4+ [submodule "edu "]
5+ path = edu
6+ url = https://github.com/mrtechtroid/edu.git
7+ [submodule "GameHub "]
8+ path = GameHub
9+ url = https://github.com/mrtechtroid/GameHub.git
10+ [submodule "2048 "]
11+ path = 2048
12+ url = https://github.com/mrtechtroid/2048.git
13+ [submodule "r "]
14+ path = r
15+ url = https://github.com/mrtechtroid/r.git
You can’t perform that action at this time.
0 commit comments