Files
dotnet__skills/.github/workflows/reference-validation.yml
Dan Moseley 74c4a1c7ac Fix PowerShell parsing of three-dot diff range in reference scanner (#359)
When pwsh parses git diff --name-only "origin/main"...HEAD, the
partially-quoted argument is tokenized incorrectly, causing git to
receive malformed arguments and print its usage message.

Build the range string in a variable first so it is passed to git as
a single token.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-13 12:13:34 -06:00

68 lines
2.0 KiB
YAML

name: Reference Validation
on:
pull_request:
paths:
- 'plugins/**'
- '.agents/**'
- 'agentic-workflows/**'
- 'eng/dashboard/**'
- 'README.md'
- 'eng/reference-scanner/**'
push:
branches: [main]
paths:
- 'plugins/**'
- '.agents/**'
- 'agentic-workflows/**'
- 'eng/dashboard/**'
- 'README.md'
- 'eng/reference-scanner/**'
workflow_dispatch:
jobs:
scan-references:
name: Scan external references
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
fetch-depth: 0
- name: Run reference scanner
shell: pwsh
run: |
if ($env:GITHUB_EVENT_NAME -ne 'pull_request') {
Write-Host "Push or manual trigger -- running full scan."
./eng/reference-scanner/scan.ps1 -All
exit $LASTEXITCODE
}
# On PRs, scan only changed files to avoid failing on pre-existing issues
git fetch origin $env:GITHUB_BASE_REF
if ($LASTEXITCODE -ne 0) {
Write-Host "::error::Failed to fetch base branch '$env:GITHUB_BASE_REF'"
exit 1
}
$range = "origin/$env:GITHUB_BASE_REF...HEAD"
$diffOutput = @(git diff --name-only $range)
if ($LASTEXITCODE -ne 0) {
Write-Host "::error::git diff failed -- cannot determine changed files"
exit 1
}
$changedFiles = @($diffOutput | Where-Object { $_ -match '\.(md|html)$' })
if ($changedFiles.Count -eq 0) {
Write-Host "No changed .md or .html files in this PR. Nothing to scan."
exit 0
}
Write-Host "Scanning $($changedFiles.Count) changed file(s):"
$changedFiles | ForEach-Object { Write-Host " $_" }
./eng/reference-scanner/scan.ps1 -Paths $changedFiles
exit $LASTEXITCODE