-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from Pxtl/updates
modernize Sandra.snow somewhat
- Loading branch information
Showing
30 changed files
with
387 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Build Snow | ||
# compile Sandra.Snow binary in release mode and publish as artifact "Snow" | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
paths: | ||
- 'src/**' | ||
- '.github/workflows/build-snow.yml' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup NuGet | ||
uses: NuGet/[email protected] | ||
- name: setup-msbuild | ||
uses: microsoft/[email protected] | ||
- name: Restore Packages | ||
run: nuget restore src/Sandra.Snow.sln | ||
- name: Build solution | ||
run: msbuild src/Sandra.Snow.sln -t:rebuild -property:Configuration=Release | ||
- name: Upload a Build Artifact | ||
uses: actions/[email protected] | ||
with: | ||
# Artifact name | ||
name: Snow | ||
# A file, directory or wildcard pattern that describes what to upload | ||
path: src/Snow/bin/Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Publish Website | ||
Check warning on line 1 in .github/workflows/publish-website.yml GitHub Actions / publish
|
||
# publish SnowSite to the repo set in vars.WEBSITE_REPO, using the pat defined in secrets.WEBSITE_PAT | ||
# note that this action overrides the output paths set in the snow config file | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'SnowSite/**' | ||
- '.github/workflows/publish-website.yml' | ||
workflow_dispatch: | ||
workflow_run: | ||
workflows: ["Build Snow"] | ||
types: | ||
- completed | ||
|
||
env: | ||
YAML_PATH: .github/workflows/publish-website.yml | ||
IS_WEBSITE_REPO_SET: ${{ vars.WEBSITE_REPO != null }} | ||
IS_WEBSITE_PAT_SET: ${{ secrets.WEBSITE_PAT != null }} | ||
|
||
jobs: | ||
publish: | ||
runs-on: windows-latest | ||
steps: | ||
- name: Check WEBSITE_REPO var | ||
if: ${{ env.IS_WEBSITE_REPO_SET == 'false' }} | ||
shell: pwsh | ||
run: | | ||
"::warning file=$env:YAML_PATH::Mandatory repo variable WEBSITE_REPO is not set." | ||
- name: Check WEBSITE_PAT secret | ||
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' && env.IS_WEBSITE_PAT_SET == 'false' }} | ||
shell: pwsh | ||
run: | | ||
"::error file=$env:YAML_PATH::Mandatory repo secret WEBSITE_PAT is not set." | ||
- name: Checkout SnowSite | ||
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }} | ||
uses: actions/checkout@v3 | ||
with: | ||
sparse-checkout: SnowSite | ||
path: doc | ||
|
||
- name: Checkout Website | ||
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }} | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ vars.WEBSITE_REPO }} | ||
path: website | ||
token: ${{ secrets.WEBSITE_PAT }} | ||
|
||
- name: Download Snow artifact | ||
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }} | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: build-snow.yml | ||
|
||
- name: run Snow | ||
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }} | ||
shell: pwsh | ||
run: | | ||
$ErrorActionPreference = 'Stop' | ||
$blogDir = (mkdir ".\website" -force).FullName | ||
$docDir = ".\doc\SnowSite" | ||
"Configuring git..." | ||
pushd $docDir | ||
$lastMessage = git log -1 --pretty=%B | Select-Object -First 1 | ||
$lastUserName = git log -1 --pretty=format:'%an' | Select-Object -First 1 | ||
$lastUserEamil = git log -1 --pretty=format:'%ae' | Select-Object -First 1 | ||
git config --global user.name "github actions bot (on behalf of $lastUserName)" | ||
git config --global user.email $lastUserEamil | ||
git config --global core.autocrlf false | ||
popd | ||
"Overriding output dirs to $blogDir" | ||
$configPath = "$docDir\Snow\Snow.config.json" | ||
$config = Get-Content $configPath | ConvertFrom-Json | ||
$config.postsOutput = $blogDir | ||
$config.pagesOutput = $blogDir | ||
$config | ConvertTo-Json | Out-File $configPath | ||
"Running Snow..." | ||
& Snow\Snow.exe "config=$configPath" | ||
Write-Output "Updating $blogdir..." | ||
cd $blogdir | ||
Get-Location #DEBUG | ||
git add . | ||
git commit -m "Publish: $lastMessage" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
& src\Snow\bin\Debug\Snow config=.\SnowSite\Snow\Snow.config.json debug=true server=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#.SYNOPSIS | ||
# Simple 1-step publish script, but has many assumptions. See description. | ||
|
||
#.DESCRIPTION | ||
# This publish is a simple local convenience measure for publishing SnowSite | ||
# from localhost to your gitrepo, assuming you've customized SnowSite to become | ||
# your site. | ||
# | ||
# It also assumes you've already compiled Sandra.snow in "debug" mode. | ||
# | ||
# It also assumes that your "config" is set to output directly into your target | ||
# static site repo. | ||
# | ||
# If any of these assumptions are false, you may need to use a different publish | ||
# script, or customize this one. | ||
|
||
param ( | ||
# git commit message for both Sandra.Snow repo and output repo. | ||
[Parameter(mandatory)] | ||
[string] $commitMessage, | ||
|
||
# path to the config file. Must be in the site directory. Defaults to SnowSite\Snow\Snow.config | ||
[Parameter()] | ||
[IO.FileInfo] $configPath = $null | ||
) | ||
|
||
Push-Location $PSScriptRoot | ||
|
||
# defaulting. | ||
if (-not $configPath) { | ||
$configPath = [IO.FileInfo](Resolve-Path ".\SnowSite\Snow\Snow.config.json").Path | ||
} | ||
$configDirPath = Split-Path $configPath -Parent | ||
$outputPath = Resolve-Path (Join-Path $configDirPath $config.postsOutput) | ||
|
||
& src\Snow\bin\Debug\Snow config=$configPath | ||
|
||
#region commits | ||
git add . | ||
git commit -m $message | ||
git push | ||
|
||
Push-Location $outputPath | ||
git add . | ||
git commit -m $message | ||
git push | ||
Pop-Location | ||
#endregion commits | ||
|
||
Pop-Location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="FakeItEasy" version="1.22.0" targetFramework="net40" /> | ||
<package id="Nancy" version="0.23.2" targetFramework="net40" /> | ||
<package id="Nancy" version="1.4.5" targetFramework="net48" /> | ||
<package id="xunit" version="1.9.2" targetFramework="net40" /> | ||
</packages> |
Oops, something went wrong.