From 3e801f5252c8a2b35f9f1c6858f8b97b0196ed83 Mon Sep 17 00:00:00 2001 From: Calvin Wilkinson Date: Mon, 25 Sep 2023 09:33:16 +0100 Subject: [PATCH] feat: add more validation for build-config workflow input --- .github/workflows/build-csharp-project.yml | 6 ++++++ .github/workflows/run-csharp-tests.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/build-csharp-project.yml b/.github/workflows/build-csharp-project.yml index f4f64c6b..a81c31f5 100644 --- a/.github/workflows/build-csharp-project.yml +++ b/.github/workflows/build-csharp-project.yml @@ -68,6 +68,12 @@ jobs: } + if ("${{ inputs.build-config }}" -ne "Debug" -and "${{ inputs.build-config }}" -ne "Release") { + Write-Host "::error::The 'build-config' workflow input is invalid. Expected values: 'Debug' or 'Release'"; + exit 1; + } + + # Verify that the dotnet sdk version has valid syntax if ($sdkVersion -match "[0-9]+\.[0-9]+\.[0-9]+") { Write-Host "::notice::The 'net-sdk-version' workflow input is valid."; diff --git a/.github/workflows/run-csharp-tests.yml b/.github/workflows/run-csharp-tests.yml index 8d72c317..4cf4f330 100644 --- a/.github/workflows/run-csharp-tests.yml +++ b/.github/workflows/run-csharp-tests.yml @@ -68,6 +68,12 @@ jobs: } + if ("${{ inputs.build-config }}" -ne "Debug" -and "${{ inputs.build-config }}" -ne "Release") { + Write-Host "::error::The 'build-config' workflow input is invalid. Expected values: 'Debug' or 'Release'"; + exit 1; + } + + $sdkVersion = "${{ inputs.net-sdk-version }}".Trim().ToLower(); # Verify that the dotnet sdk version has valid syntax