Add daily API docs update workflow#63
Conversation
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit 8cca112: ✅ Validation status: passed
For more details, please refer to the build report. |
The workflow now lives in the docs repo (mono/SkiaSharp-API-docs#63) where GITHUB_TOKEN has native write access, eliminating the need for cross-repo PATs or deploy keys. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8cca112 to
96d714b
Compare
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit 96d714b: ✅ Validation status: passed
For more details, please refer to the build report. |
Full workflow that checks out mono/SkiaSharp at a configurable branch, installs GTK# 2 MSI, and runs Cake doc generation targets. Supports a skiasharp-branch parameter to generate docs from any SkiaSharp branch. Schedule: daily at 6 AM UTC, plus manual workflow_dispatch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
96d714b to
c3045cf
Compare
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit c3045cf: ✅ Validation status: passed
For more details, please refer to the build report. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new GitHub Actions workflow that automates the daily update of API documentation for SkiaSharp. The workflow checks out the SkiaSharp repository to access Cake build scripts, downloads the latest CI NuGet packages, generates XML API documentation, and automatically creates a pull request with any documentation changes.
Changes:
- Adds a new workflow file that runs daily at 6 AM UTC and can be manually triggered
- Checks out both the mono/SkiaSharp repository (for Cake scripts) and the docs repository
- Installs GTK# 2 as a dependency, downloads NuGet packages, and regenerates API docs using Cake tasks
- Automatically creates or updates a PR if documentation changes are detected
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| run: | | ||
| cd docs | ||
| git add -A | ||
| git diff --cached --quiet | ||
| if ($LASTEXITCODE -eq 0) { | ||
| Write-Host "No documentation changes detected" | ||
| exit 0 | ||
| } |
There was a problem hiding this comment.
In GitHub Actions PowerShell steps, $ErrorActionPreference is set to 'Stop' by default, which means git diff --cached --quiet will throw an error when it exits with code 1 (indicating changes exist). This will cause the step to fail before $LASTEXITCODE can be checked. Add $ErrorActionPreference = 'Continue' at the start of the script block, or check the exit code explicitly with a command like git diff --cached --quiet; $hasChanges = $LASTEXITCODE -ne 0.
| $msiUrl = "https://github.com/mono/gtk-sharp/releases/download/2.12.45/gtk-sharp-2.12.45.msi" | ||
| $msiPath = "$env:RUNNER_TEMP\gtk-sharp.msi" | ||
| Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath | ||
| Start-Process msiexec.exe -ArgumentList "/i", $msiPath, "/quiet", "/norestart" -Wait -NoNewWindow |
There was a problem hiding this comment.
The GTK# installation step does not verify whether the MSI installation completed successfully. Consider checking the exit code of the msiexec process and failing the workflow if the installation fails, as this is a required dependency for the docs generation. You can add -PassThru to Start-Process and check its ExitCode property.
| Start-Process msiexec.exe -ArgumentList "/i", $msiPath, "/quiet", "/norestart" -Wait -NoNewWindow | |
| $process = Start-Process msiexec.exe -ArgumentList "/i", $msiPath, "/quiet", "/norestart" -Wait -NoNewWindow -PassThru | |
| if ($process.ExitCode -ne 0) { | |
| Write-Error "GTK# installation failed with exit code $($process.ExitCode)." | |
| exit $process.ExitCode | |
| } |
| git commit -m "Update API docs from latest CI build" | ||
| git push origin automation/update-api-docs --force | ||
| # Create PR if one doesn't already exist | ||
| $existing = gh pr list --head automation/update-api-docs --state open --json number --jq '.[0].number' |
There was a problem hiding this comment.
The gh pr list command with --jq '.[0].number' will return an empty string if no PRs exist, but if the command itself fails (e.g., network issues, auth problems), it may also return empty or cause an error. Consider adding explicit error handling for the gh commands to distinguish between "no PR exists" and "command failed". For example, check $LASTEXITCODE after the gh pr list command.
| $existing = gh pr list --head automation/update-api-docs --state open --json number --jq '.[0].number' | |
| $existing = gh pr list --head automation/update-api-docs --state open --json number --jq '.[0].number' | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Error "Failed to list existing pull requests. 'gh pr list' exited with code $LASTEXITCODE." | |
| exit $LASTEXITCODE | |
| } |
| $msiPath = "$env:RUNNER_TEMP\gtk-sharp.msi" | ||
| Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath |
There was a problem hiding this comment.
The workflow downloads and installs the GTK# MSI without verifying its integrity using a checksum. While the source is trusted (mono/gtk-sharp), consider adding a SHA256 checksum verification after downloading the MSI to ensure it hasn't been tampered with. This follows security best practices for downloading and executing external binaries.
| $msiPath = "$env:RUNNER_TEMP\gtk-sharp.msi" | |
| Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath | |
| $msiPath = "$env:RUNNER_TEMP\gtk-sharp.msi" | |
| $expectedHash = "<REPLACE_WITH_ACTUAL_SHA256_OF_gtk-sharp-2.12.45.msi>" | |
| Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath | |
| $actualHash = (Get-FileHash -Path $msiPath -Algorithm SHA256).Hash.ToLowerInvariant() | |
| if ($actualHash -ne $expectedHash.ToLowerInvariant()) { | |
| Write-Error "GTK# MSI SHA256 mismatch. Expected: $expectedHash, Actual: $actualHash" | |
| throw "Downloaded GTK# MSI failed integrity check." | |
| } |
| - name: Download latest NuGet packages | ||
| run: dotnet cake --target=docs-download-output | ||
|
|
||
| - name: Regenerate API docs | ||
| run: dotnet cake --target=update-docs |
There was a problem hiding this comment.
The Cake commands on lines 52 and 55 are executed from the SkiaSharp repository root, but it's not clear whether these Cake tasks expect the docs repository to be in the docs/ subdirectory. If the Cake scripts have hardcoded paths or different expectations, these commands might fail. Consider adding a comment documenting this assumption or verifying that the Cake tasks are configured to use the docs/ path.
Summary
Full self-contained workflow that generates XML API docs from SkiaSharp CI NuGet packages.
How it works
mono/SkiaSharpat a configurable branch (default:main) — no submodules, just the Cake scriptsdocs/directorymdoc.exeforSkiaSharp.Views.Gtk)dotnet cake --target=update-docsParameters
main)Schedule
Daily at 6 AM UTC + manual
workflow_dispatchWhy in this repo?
GITHUB_TOKENhas native write access to its own repo — no PATs, deploy keys, or GitHub Apps needed.Related