Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/actions/has-changes/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,26 @@ runs:
param ($CsprojPath, $CurrentHash, $PrevHash)

$projectDirectoryPath = "$(Split-Path -Path $CsprojPath)"
Write-Host "Checking changes in: $projectDirectoryPath"
$output = $(git diff --quiet "$($CurrentHash):$($projectDirectoryPath -replace '\\', '/')" "$($PrevHash):$($projectDirectoryPath -replace '\\', '/')" -- ':!*.nuspec'; $LASTEXITCODE -ne 0)

if ($output) {
Write-Host " -> Direct changes detected in $projectDirectoryPath"
return $output;
}

$csproj = [xml](Get-Content "$($CsprojPath)")
$projectReferences = $csproj.Project.ItemGroup.ProjectReference | Where-Object { $_ -ne $null }
Write-Host " -> Checking $($projectReferences.Count) project references"
foreach ($projectReference in $projectReferences) {
if (-not([string]::IsNullOrWhitespace($projectReference.IncludeAssets)) -and $projectReference.IncludeAssets -ne "All") {
Write-Host " -> Skipping reference (IncludeAssets != All): $($projectReference.Include)"
continue;
}

$output = HasChanges -CsprojPath "$(Resolve-RelativePath $([IO.Path]::Combine($projectDirectoryPath, $projectReference.Include)))" -CurrentHash $CurrentHash -PrevHash $PrevHash
$refPath = "$(Resolve-RelativePath $([IO.Path]::Combine($projectDirectoryPath, $projectReference.Include)))"
Write-Host " -> Checking reference: $refPath"
$output = HasChanges -CsprojPath $refPath -CurrentHash $CurrentHash -PrevHash $PrevHash
if ($output) {
break;
}
Expand All @@ -79,30 +85,39 @@ runs:
}

$SelectedProject = "${{ inputs.project }}"
Write-Host "Checking project: $SelectedProject"

$currentHash = git rev-parse HEAD
if (-not $currentHash) {
Write-Host "Cannot fetch hash of HEAD"
exit 1
}
Write-Host "Current hash: $currentHash"

# Fetch hash of last release based on the project input
$lastReleaseHash = git tag -l "$($SelectedProject)/*" | Sort-Object { [version]($_ -split '/' | Select-Object -Last 1) } | Select-Object -Last 1 | ForEach-Object { git rev-list -n 1 $_ }
if (-not $lastReleaseHash) {
Write-Host "Cannot fetch hash of last release"
exit 1
}
Write-Host "Last release hash: $lastReleaseHash"

$csProjPath = "$([IO.Path]::Combine(".", "$($SelectedProject)", "$($SelectedProject).csproj"))"
Write-Host "Starting change detection for: $csProjPath"
$hasDifferences = HasChanges -CsprojPath $csProjPath -CurrentHash $currentHash -PrevHash $lastReleaseHash

if ($hasDifferences) {
Write-Host "Changes detected, checking nuspec..."
$nuspecPath = "$([IO.Path]::Combine(".", "$($SelectedProject)", "$($SelectedProject).nuspec"))"
[xml]$nuspec = Get-Content $nuspecPath
$hashFromNuspec = $nuspec.package.metadata.repository.commit
if ($hashFromNuspec) {
Write-Host "Nuspec commit hash found: $hashFromNuspec - rechecking against this hash"
$hasDifferences = HasChanges -CsprojPath $csProjPath -CurrentHash $currentHash -PrevHash $hashFromNuspec
}
}

Write-Host "Final result: $hasDifferences"
"result=$("$($hasDifferences)".ToLowerInvariant())" >> $env:GITHUB_OUTPUT
exit 0

4 changes: 2 additions & 2 deletions .github/workflows/auto-complete-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Auto-Complete PR

on:
schedule:
# Run every 3 hours
- cron: '0 */3 * * *'
# Run every 6 hours
- cron: '0 */6 * * *'
workflow_dispatch:

permissions:
Expand Down
Loading