-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathreleaseDocs.ps1
More file actions
49 lines (41 loc) · 1.57 KB
/
releaseDocs.ps1
File metadata and controls
49 lines (41 loc) · 1.57 KB
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
param(
[string]$ACTOR="user",
[string]$TOKEN="password"
)
write-host "Build the documentation site"
write-host "`ACTOR is $ACTOR"
$SOURCE_DIR=$psscriptroot
$TEMP_REPO_DIR=[System.IO.Path]::GetFullPath("$psscriptroot/../docs-gh-pages")
$remote_repo="https://github-actions:${TOKEN}@github.com/rws/studio-api-docs.git"
write-host "==> Cloning the repo $remote_repo with the gh-pages branch"
git clone $remote_repo --branch gh-pages $TEMP_REPO_DIR
Set-Location $TEMP_REPO_DIR
#delete gh-pages_temp branch if already exist
$checkBranch = git show-ref origin/gh-pages_temp
Write-Output($checkBranch)
if($checkBranch){
Write-Output("delete existing branch gh-pages_temp")
git push origin --delete gh-pages_temp
}
git checkout -b gh-pages_temp
$items = Get-ChildItem
$keepVersions = @("15.2", "16.1", "16.2", "17.0", "17.1", "17.2", "18.0", "18.1")
foreach ($item in $items)
{
write-host "==> Checking $($item.Name) for deletion"
if ($item.Name -notin $keepVersions)
{
write-host "==> Deleting $($item.Name)"
git rm $item -r
}
}
write-host "==>Copy documentation into the repo"
Copy-Item "$SOURCE_DIR\_site\*" .\ -Recurse -force
write-host "Push the new docs to the remote branch"
git config --local user.email "github-actions[bot]@users.noreply.sdl.com"
git config --local user.name "github-actions[bot]"
git add .\ -A
git commit -m "Update generated documentation"
git push "$remote_repo" HEAD:gh-pages_temp
Write-Output (${TOKEN}) | gh auth login --with-token
gh pr create --title "Update generated documentation" --body "Update generated documentation" -H gh-pages_temp -B gh-pages