forked from unic/bob-keith
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pushDocs.ps1
34 lines (28 loc) · 980 Bytes
/
pushDocs.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
param([string]$buildFolder, [string]$docSource, [string]$repoUrl)
$workingDir = "$($buildFolder)\..\gh-pages"
$workingBranch = "gh-pages"
Push-Location
if (Test-Path("$($workingDir)")) {
Remove-Item "$($workingDir)" -Recurse -Force
}
mkdir $workingDir
git clone --quiet --branch=$workingBranch "$($repoUrl)" "$($workingDir)"
cd $($workingDir)
git status
Get-ChildItem -Attributes !r | Remove-Item -Recurse -Force
Copy-Item -Path "$($buildFolder)\$($docSource)\**" -Destination $pwd.Path -Recurse
git status
$thereAreChanges = git status | select-string -pattern "Changes not staged for commit:","Untracked files:" -simplematch
if ($thereAreChanges -ne $null) {
Write-Host "Committing changes to docs..."
git add --all
git status
git commit -m "CI build"
git status
git push -q
Write-Host "Changes pushed succesfully" -ForegroundColor Green
}
else {
Write-Host "No changes to documentation to commit" -ForegroundColor Blue
}
Pop-Location