-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPush-Docs.ps1
42 lines (36 loc) · 1.23 KB
/
Push-Docs.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
35
36
37
38
39
40
41
42
if($env:APPVEYOR_PULL_REQUEST_NUMBER)
{
return;
}
# Docs must only be updated from a build with the official repo as the default remote.
# This ensures that the links to source in the generated docs will have the correct URLs
# (e.g. docs pushed to the official repo MUST not have links to source in some private fork)
$remoteUrl = git ls-remote --get-url
if($remoteUrl -ne "https://github.com/UbiquityDotNET/CommandlineParsing.git")
{
throw "Pushing docs is only allowed when the origin remote is the official source release"
}
if($env:APPVEYOR)
{
git config --global credential.helper store
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:docspush_access_token):[email protected]`n"
git config --global user.email "$env:docspush_email"
git config --global user.name "$env:docspush_username"
}
pushd .\BuildOutput\docs -ErrorAction Stop
try
{
# prevent line ending conversions
git config core.safecrlf false
git config core.autocrlf input
Write-Information "Adding files to git"
git add *
Write-Information "Commiting changes to git"
git commit -m "CI Docs Update ($env:APPVEYOR_BUILD_VERSION)"
Write-Information "pushing changes to git"
git push -q
}
finally
{
popd
}