Skip to content

Instantly share code, notes, and snippets.

@rfennell
Created March 22, 2024 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfennell/2f487c9068b9b1a5d67e23b7f9f5fdd9 to your computer and use it in GitHub Desktop.
Save rfennell/2f487c9068b9b1a5d67e23b7f9f5fdd9 to your computer and use it in GitHub Desktop.
When run in a Hugo based Static website Git Repo will copy content to another repo
param (
[string]$blog = "rfennell",
[string]$destination = "C:\projects\bm-source\BMBlogs-Hugo"
)
write-host "Copying last blog commit"
$commandOutput = Invoke-Expression "git diff-tree --no-commit-id --name-only -r HEAD"
foreach ($sourceFile in $commandOutput) {
# sourceFile ends with /md
if ($sourceFile -like "*.md") {
$destinationFile = $destination + "/" + $sourceFile.Replace("content", "content/$blog/").Replace("/posts", "")
}
if ($sourceFile -notlike "*.md") {
$destinationFile = $destination + "/" + $sourceFile
}
write-host "Copying " $sourceFile " to " $destinationFile
Copy-Item $sourceFile $destinationFile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment