This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
forked from UbiquityDotNET/Llvm.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPush-Docs.ps1
81 lines (67 loc) · 1.98 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Param(
[switch]$SkipPush
)
. .\buildutils.ps1
$buildInfo = Initialize-BuildEnvironment
Write-Information "Preparing to PUSH updated docs to GitHub IO"
$canPush = $env:IsAutomatedBuild -and ($env:IsPullRequestBuild -ieq 'false')
if(!$canPush)
{
Write-Information "Skipping Docs PUSH as this is not an official build"
return;
}
# Docs must only be updated from a build with the official repository 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 repository MUST not have links to source in some private fork)
$remoteUrl = git ls-remote --get-url
Write-Information "Remote URL: $remoteUrl"
if(!($remoteUrl -like "https://github.com/UbiquityDotNET/Llvm.NET*"))
{
throw "Pushing docs is only allowed when the origin remote is the official source release current remote is '$remoteUrl'"
}
if(!$env:docspush_access_token -and !$SkipPush)
{
Write-Error "Missing docspush_access_token"
}
if(!$env:docspush_email)
{
Write-Error "Missing docspush_email"
}
if(!$env:docspush_username)
{
Write-Error "Missing docspush_username"
}
pushd .\BuildOutput\docs -ErrorAction Stop
try
{
if($env:docspush_access_token)
{
git config --local credential.helper store
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:docspush_access_token):[email protected]`n"
}
git config --local user.email "$env:docspush_email"
git config --local user.name "$env:docspush_username"
Write-Information 'Adding files to git'
git add -A
git ls-files -o --exclude-standard | %{ git add $_}
if(!$?)
{
throw "git add failed"
}
$msg = "CI Docs Update $(Get-BuildVersionTag)"
Write-Information "Committing changes to git [$msg]"
git commit -m"$msg"
if(!$?)
{
throw "git commit failed"
}
if(!$SkipPush)
{
Write-Information 'Pushing changes to git'
git push
}
}
finally
{
popd
}