Created
December 19, 2023 16:22
-
-
Save apgapg/3b818868a63ce106b22c651e060594e5 to your computer and use it in GitHub Desktop.
Replace url with PAT in github root and nested submodules
This file contains 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
#!/bin/bash | |
# Root project having .gitmodules | |
PROJECT[0]="." | |
# Another project inside root project having .gitmodules | |
PROJECT[1]="project1" | |
for i in "${PROJECT[@]}" | |
do | |
cd $i | |
FILE_PATH=".gitmodules" | |
git config --file $FILE_PATH --get-regexp url | while read url; do | |
git config --file=$FILE_PATH $(echo "$url" | sed -E "s|github.com/|${{ secrets.CUSTOM_GITHUB_API_TOKEN }}@github.com/|") | |
done | |
git submodule sync && git submodule update --init | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment