Add GitHub Actions workflow to build website via Nuke and Jekyll#391
Add GitHub Actions workflow to build website via Nuke and Jekyll#391
Conversation
Agent-Logs-Url: https://github.com/dennisdoomen/CSharpGuidelines/sessions/be493e29-c6b7-45c4-ad17-0f4eb771419f Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dennisdoomen/CSharpGuidelines/sessions/be493e29-c6b7-45c4-ad17-0f4eb771419f Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
|
…uke + Jekyll jobs Agent-Logs-Url: https://github.com/dennisdoomen/CSharpGuidelines/sessions/9daf6d89-e2b4-47fd-95d5-54e4eba9f9d1 Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dennisdoomen/CSharpGuidelines/sessions/9daf6d89-e2b4-47fd-95d5-54e4eba9f9d1 Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Done in commit 55d76a8. Nuke build project ( Jekyll steps added: A new Updated workflow: jobs:
build: # windows-latest: dotnet run --project build/_build.csproj -- Default
jekyll: # ubuntu-latest: bundle exec jekyll build |
| # - Nuke compiles the guidelines into standalone HTML documents using Pandoc | ||
| # - Jekyll builds the static website from the same source Markdown files | ||
| # They share no artifacts and can run in parallel. | ||
| jekyll: |
There was a problem hiding this comment.
I want this to be part of the Nuke script as well.
There was a problem hiding this comment.
Done in commit 509774e. Added a JekyllBuild target to build/Build.cs:
Target JekyllBuild => _ => _
.Executes(() =>
{
ProcessTasks.StartProcess("bundle", "exec jekyll build", RootDirectory)
.AssertZeroExitCode();
});The jekyll CI job now invokes this via ./build.sh JekyllBuild instead of calling bundle exec jekyll build directly.
There was a problem hiding this comment.
@copilot Then you can remove it from the build.yml, right?
There was a problem hiding this comment.
Done in commit f16399c. ruby/setup-ruby@v1 is removed from the workflow. The jekyll job now just does checkout + ./build.sh JekyllBuild.
.github/workflows/build.yml
Outdated
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-dotnet@v4 |
There was a problem hiding this comment.
This is not needed as the Nuke build.ps1 should do this for you.
There was a problem hiding this comment.
Done in commit 509774e. The actions/setup-dotnet@v4 step has been removed. build.ps1 detects dotnet on PATH (GitHub runners already have it) and falls back to downloading and installing it only when needed.
.github/workflows/build.yml
Outdated
| dotnet-version: '8.0.x' | ||
|
|
||
| - name: Run Nuke build | ||
| run: dotnet run --project build/_build.csproj -- Default |
There was a problem hiding this comment.
Use the standard build.ps1 Nuke adds to a project
There was a problem hiding this comment.
Done in commit 509774e. Added the standard Nuke bootstrap scripts (build.ps1 for Windows, build.sh for Unix) taken from Nuke's official template. The workflow now uses .\build.ps1 Default for the Windows build job and ./build.sh JekyllBuild for the Linux Jekyll job.
build/Build.cs
Outdated
| .DependsOn(Clean) | ||
| .Executes(() => | ||
| { | ||
| var gitVersionExe = LibDirectory / "GitVersion.exe"; |
There was a problem hiding this comment.
GitVersion is a built-in feature of Nuke. Use that instead.
There was a problem hiding this comment.
Done in commit 509774e. Replaced ProcessTasks.StartProcess with GitVersionTasks.GitVersion() from Nuke.Common.Tools.GitVersion, using SetProcessToolPath to point to the bundled Lib/GitVersion.exe:
var result = GitVersionTasks.GitVersion(s => s
.SetProcessToolPath(LibDirectory / "GitVersion.exe")
.SetProcessWorkingDirectory(RootDirectory));
semVer = result.Result.SemVer;
commitDate = DateTime.Parse(result.Result.CommitDate).ToString("MMMM d, yyyy");…rap scripts Agent-Logs-Url: https://github.com/dennisdoomen/CSharpGuidelines/sessions/0b55473b-439d-48f6-9e34-821c3a275191 Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
| contents: read | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 |
There was a problem hiding this comment.
@copilot Running Jekyll should also become part of the Nuke script
There was a problem hiding this comment.
Done in commit f16399c. bundle install is now part of the JekyllBuild Nuke target, so the Nuke script handles the full Jekyll setup:
Target JekyllBuild => _ => _
.Executes(() =>
{
ProcessTasks.StartProcess("bundle", "install", RootDirectory)
.AssertZeroExitCode();
ProcessTasks.StartProcess("bundle", "exec jekyll build", RootDirectory)
.AssertZeroExitCode();
});…uby from workflow Agent-Logs-Url: https://github.com/dennisdoomen/CSharpGuidelines/sessions/5b7725a1-5ddb-4b6d-97e4-804973568313 Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Adds
.github/workflows/build.yml— a CI workflow that runs on every push and pull request tomasterwith two independent parallel jobs:Nuke build job (
windows-latest):Build/default.ps1) into a C#/Nuke build project (build/_build.csproj+build/Build.cs) usingNuke.CommonClean,ExtractVersionsFromGit,Compile,CompileCheatsheet, andBuildHtmlGitVersionTasks(withSetProcessToolPathpointing to the bundledLib/GitVersion.exe) instead of raw process invocationLib/Pandoc/pandoc.exefor HTML generation (requiresfetch-depth: 0for GitVersion).\build.ps1 DefaultJekyll build job (
ubuntu-latest):JekyllBuildNuke target via./build.sh JekyllBuildto verify the static site compiles correctlyJekyllBuildNuke target handles the full Jekyll setup: runsbundle installthenbundle exec jekyll build— no Ruby tooling configured in the workflow YAMLKey details:
GITHUB_TOKENpermissions are restricted tocontents: readon both jobsbuild.ps1/build.sh) handle .NET SDK detection and installation automatically — no separatesetup-dotnetstep neededbuild/bin/,build/obj/) and the Nuke temp directory (.nuke/temp/) are excluded via.gitignore