Skip to content

Add daily API docs update workflow#63

Merged
mattleibow merged 1 commit into
mainfrom
automation/add-update-workflow
Feb 27, 2026
Merged

Add daily API docs update workflow#63
mattleibow merged 1 commit into
mainfrom
automation/add-update-workflow

Conversation

@mattleibow

@mattleibow mattleibow commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Full self-contained workflow that generates XML API docs from SkiaSharp CI NuGet packages.

How it works

  1. Checks out mono/SkiaSharp at a configurable branch (default: main) — no submodules, just the Cake scripts
  2. Checks out this docs repo into the docs/ directory
  3. Installs GTK# 2 MSI (required by mdoc.exe for SkiaSharp.Views.Gtk)
  4. Downloads latest NuGet packages from the public CI feed
  5. Runs dotnet cake --target=update-docs
  6. If changes detected, creates a PR

Parameters

  • skiasharp-branch: SkiaSharp branch to check out for Cake scripts + version info (default: main)

Schedule

Daily at 6 AM UTC + manual workflow_dispatch

Why in this repo?

GITHUB_TOKEN has native write access to its own repo — no PATs, deploy keys, or GitHub Apps needed.

Related

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 8cca112:

✅ Validation status: passed

File Status Preview URL Details
.github/workflows/update-docs.yml ✅Succeeded

For more details, please refer to the build report.

mattleibow added a commit to mono/SkiaSharp that referenced this pull request Feb 27, 2026
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>
@mattleibow mattleibow force-pushed the automation/add-update-workflow branch from 8cca112 to 96d714b Compare February 27, 2026 09:25
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 96d714b:

✅ Validation status: passed

File Status Preview URL Details
.github/workflows/update-docs.yml ✅Succeeded

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>
@mattleibow mattleibow force-pushed the automation/add-update-workflow branch from 96d714b to c3045cf Compare February 27, 2026 09:58
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit c3045cf:

✅ Validation status: passed

File Status Preview URL Details
.github/workflows/update-docs.yml ✅Succeeded

For more details, please refer to the build report.

@mattleibow mattleibow requested a review from Copilot February 27, 2026 10:20
@mattleibow mattleibow merged commit 5c06f29 into main Feb 27, 2026
5 checks passed
@mattleibow mattleibow deleted the automation/add-update-workflow branch February 27, 2026 10:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +61 to +68
run: |
cd docs
git add -A
git diff --cached --quiet
if ($LASTEXITCODE -eq 0) {
Write-Host "No documentation changes detected"
exit 0
}

Copilot AI Feb 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
$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

Copilot AI Feb 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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
}

Copilot uses AI. Check for mistakes.
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'

Copilot AI Feb 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
$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
}

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +45
$msiPath = "$env:RUNNER_TEMP\gtk-sharp.msi"
Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath

Copilot AI Feb 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
$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."
}

Copilot uses AI. Check for mistakes.
Comment on lines +51 to +55
- name: Download latest NuGet packages
run: dotnet cake --target=docs-download-output

- name: Regenerate API docs
run: dotnet cake --target=update-docs

Copilot AI Feb 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants