-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.ps1
29 lines (22 loc) · 964 Bytes
/
publish.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
Param(
[string]$GITHUB_TOKEN
)
$ErrorActionPreference = 'Stop'
# Create the release
dotnet publish .\source -c Release
# Copying the published content to the root (on GitHub Pages, that's publishing)
$rootPath = ".\"
$publishPath = ".\source\BlazorSite\bin\Release\net5.0\publish\wwwroot"
$ignored_root = @(".git", ".github", "source", "content", ".gitattributes", ".gitignore", ".nojekyll", "README.md", "publish.ps1")
$ignored_published = @("content")
Get-ChildItem -Exclude $ignored_root | Remove-Item -Recurse
Get-ChildItem $publishPath -Exclude $ignored_published | Copy-Item -Destination $rootPath -Recurse
# Git setup
git remote set-url origin https://x-access-token:${env:GITHUB_TOKEN}@github.com/${env:GITHUB_REPOSITORY}.git
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
git config --global core.autocrlf false
# Publish release
git add .
git commit -m "[Publish]"
git push origin HEAD:master