Created
March 22, 2024 09:01
-
-
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
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
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