Last active
August 5, 2024 17:00
-
-
Save ChrisHammond/fa4d181921f80b826da56ad61cb664bb to your computer and use it in GitHub Desktop.
Update GitHub Repos and Jekyll GEMFILE/Bundles
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
# This GIST goes along with a blog post at ChrisHammond.com https://www.chrishammond.com/blog/itemid/3201/using-powershell-and-windows-subsystem-for-linux-t | |
# Define the path to the file containing the list of repositories | |
$reposListPath = "YOURPATHHERE\github_io_repos.txt" | |
# sample github_io_repos.txt file | |
# YOURDRIVE:\Projects\reponame.github.io | |
# YOURDRIVE:\Projects\reponame2.github.io | |
# Read the list of repositories | |
$repos = Get-Content -Path $reposListPath | |
# Loop through each repository and update it | |
foreach ($repo in $repos) { | |
# Check if the directory exists | |
if (Test-Path -Path $repo) { | |
Write-Host "Updating repository in $repo" | |
# Perform Git pull in Windows | |
cd $repo | |
git pull | |
# Convert Windows path to WSL path | |
$wslRepoPath = $repo -replace '\\', '/' -replace 'G:', '/mnt/g' | |
# Execute bundle update in WSL | |
wsl -d Ubuntu-22.04 -- bash -c " | |
source ~/.rvm/scripts/rvm && | |
cd $wslRepoPath && | |
bundle update | |
" | |
# Perform Git add, commit, and push in Windows | |
git add . | |
git commit -m "Updates for bundle update" | |
git push | |
# Print completion message | |
Write-Host "Finished updating $repo" | |
} else { | |
Write-Host "Directory $repo does not exist" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment