Skip to content

Commit

Permalink
Fail workflow if commands fail
Browse files Browse the repository at this point in the history
Fail the GitHub Actions workflow explicitly if any dotnet command returns a non-zero exit code.
  • Loading branch information
martincostello committed Nov 13, 2024
1 parent 34bc770 commit ae63f0f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/update-dotnet-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ jobs:
Write-Host "Installing dotnet-outdated-tool..."
dotnet tool install --global dotnet-outdated-tool --version "$env:DOTNET_OUTDATED_VERSION"
if ($LASTEXITCODE -ne 0) {
Write-Host "dotnet tool install failed with code ${LASTEXITCODE}"
return 1
}
$tempPath = [System.IO.Path]::GetTempPath()
$updatesPath = (Join-Path $tempPath "dotnet-outdated.json")
Expand Down Expand Up @@ -319,6 +324,10 @@ jobs:
if (Test-Path $toolsManifest) {
Write-Host "Restoring .NET tools..."
dotnet tool restore
if ($LASTEXITCODE -ne 0) {
Write-Host "dotnet tool restore failed with code ${LASTEXITCODE}"
return 1
}
}
# .NET workloads need to be restored before running dotnet outdated.
Expand Down Expand Up @@ -347,6 +356,10 @@ jobs:
if ($restoreWorkloads) {
Write-Host "Restoring .NET workloads..."
dotnet workload restore
if ($LASTEXITCODE -ne 0) {
Write-Host "dotnet workfload restore failed with code ${LASTEXITCODE}"
return 1
}
}
}
Expand All @@ -356,6 +369,11 @@ jobs:
Write-Host "Restoring NuGet packages..."
dotnet restore
if ($LASTEXITCODE -ne 0) {
Write-Host "dotnet restore failed with code ${LASTEXITCODE}"
return 1
}
Write-Host "Checking for .NET NuGet package(s) to update..."
# The --version-lock Major option is used to only update packages
Expand All @@ -369,6 +387,11 @@ jobs:
--output $updatesPath `
$additionalArguments
if ($LASTEXITCODE -ne 0) {
Write-Host "dotnet outdated failed with code ${LASTEXITCODE}"
return 1
}
$dependencies = @()
# Determine the distinct set of package updates that were applied, if any.
Expand Down

0 comments on commit ae63f0f

Please sign in to comment.