From dbf8c162d9b940e84c761a54bd6e9d6d914d5d75 Mon Sep 17 00:00:00 2001 From: mpaulosky Date: Wed, 3 Jun 2026 14:18:17 -0700 Subject: [PATCH] ci: auto-discover root *.slnx in squad-ci and squad-test workflows Replace hardcoded MyBlog.slnx with a discovery step that finds exactly one root-level *.slnx file, exports it as SOLUTION_FILE via GITHUB_ENV, and uses that variable for restore/build. Fails with a clear error if zero or multiple solution files are found at the repo root. --- .github/workflows/squad-ci.yml | 22 ++++++++++++++++++---- .github/workflows/squad-test.yml | 18 ++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.github/workflows/squad-ci.yml b/.github/workflows/squad-ci.yml index 0ca263b7..042594bc 100644 --- a/.github/workflows/squad-ci.yml +++ b/.github/workflows/squad-ci.yml @@ -3,10 +3,10 @@ name: Squad CI on: pull_request: - branches: [dev, preview, main, insider] + branches: [dev, main] types: [opened, synchronize, reopened] push: - branches: [dev, insider] + branches: [dev] permissions: contents: read @@ -25,8 +25,22 @@ jobs: with: global-json-file: global.json + - name: Discover solution file + run: | + mapfile -t matches < <(find . -maxdepth 1 -name '*.slnx') + count=${#matches[@]} + if [[ $count -eq 0 ]]; then + echo "::error::No *.slnx file found at the repository root." + exit 1 + elif [[ $count -gt 1 ]]; then + echo "::error::Multiple *.slnx files found at the repository root: ${matches[*]}" + exit 1 + fi + echo "SOLUTION_FILE=${matches[0]}" >> "$GITHUB_ENV" + echo "Discovered solution: ${matches[0]}" + - name: Restore dependencies - run: dotnet restore MyBlog.slnx + run: dotnet restore "$SOLUTION_FILE" - name: Build (Release) - run: dotnet build MyBlog.slnx --configuration Release --no-restore + run: dotnet build "$SOLUTION_FILE" --configuration Release --no-restore diff --git a/.github/workflows/squad-test.yml b/.github/workflows/squad-test.yml index 37cfd710..2c616611 100644 --- a/.github/workflows/squad-test.yml +++ b/.github/workflows/squad-test.yml @@ -71,11 +71,25 @@ jobs: restore-keys: | ${{ runner.os }}-nuget- + - name: Discover solution file + run: | + mapfile -t matches < <(find . -maxdepth 1 -name '*.slnx') + count=${#matches[@]} + if [[ $count -eq 0 ]]; then + echo "::error::No *.slnx file found at the repository root." + exit 1 + elif [[ $count -gt 1 ]]; then + echo "::error::Multiple *.slnx files found at the repository root: ${matches[*]}" + exit 1 + fi + echo "SOLUTION_FILE=${matches[0]}" >> "$GITHUB_ENV" + echo "Discovered solution: ${matches[0]}" + - name: Restore dependencies - run: dotnet restore + run: dotnet restore "$SOLUTION_FILE" - name: Build solution - run: dotnet build MyBlog.slnx --configuration Release --no-restore + run: dotnet build "$SOLUTION_FILE" --configuration Release --no-restore - name: Cache build artifacts uses: actions/cache@v5