mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
144b129995
The PR-mode code path used --depth=1 when fetching the base branch, which prevented git from finding the merge-base for the three-dot diff. The git diff failure was silently swallowed because its stderr output was piped through Where-Object and filtered out, causing the scanner to report success without scanning anything. Fix: - Remove --depth=1 from git fetch (checkout already uses fetch-depth: 0) - Check LASTEXITCODE after both git fetch and git diff - Separate git diff from the Where-Object filter so exit code is captured Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
67 lines
2.0 KiB
YAML
67 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
|
|
}
|
|
|
|
$diffOutput = @(git diff --name-only "origin/$env:GITHUB_BASE_REF"...HEAD)
|
|
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
|