From 21630ea9fb23a40f0a9c5bfd0901c8a3291c6208 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Fri, 16 Oct 2026 20:54:19 -0400 Subject: [PATCH 1/7] Add metrics generation and PR creation steps --- .github/workflows/build-package.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/build-package.yaml b/.github/workflows/build-package.yaml index 5c88f41..e310f4d 100644 --- a/.github/workflows/build-package.yaml +++ b/.github/workflows/build-package.yaml @@ -80,6 +80,24 @@ jobs: - name: Verify packages run: ./scripts/verify-packages.sh + - name: generate stats + id: dotnet-code-metrics + uses: dotnet/samples/github-actions/DotNet.GitHubAction@main + with: + owner: ${{ github.repository_owner }} + name: ${{ github.repository }} + branch: ${{ github.ref }} + dir: ${{ './src' }} # Path to your source code directory + + - name: Create Pull Request for Metrics + uses: peter-evans/create-pull-request@v5 + if: ${{ steps.dotnet-code-metrics.outputs.updated-metrics == 'true' }} + with: + title: '${{ steps.dotnet-code-metrics.outputs.summary-title }}' + body: '${{ steps.dotnet-code-metrics.outputs.summary-details }}' + commit-message: 'docs: automated .NET code metrics update' + branch: dotnet-code-metrics-updates + # The badge lives on an orphan branch so README can link to a stable raw URL without # adding commit noise to main. - name: Publish coverage badge From a18c267d3e22a621b0494d6f19bf6c82337990d2 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Fri, 16 Oct 2026 21:14:32 -0400 Subject: [PATCH 2/7] Update build-package.yaml --- .github/workflows/build-package.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-package.yaml b/.github/workflows/build-package.yaml index e310f4d..c03058c 100644 --- a/.github/workflows/build-package.yaml +++ b/.github/workflows/build-package.yaml @@ -91,12 +91,13 @@ jobs: - name: Create Pull Request for Metrics uses: peter-evans/create-pull-request@v5 - if: ${{ steps.dotnet-code-metrics.outputs.updated-metrics == 'true' }} + if: ${{ steps.dotnet-code-metrics.outputs.updated-metrics == 'true' && github.ref == 'refs/heads/main' }} with: title: '${{ steps.dotnet-code-metrics.outputs.summary-title }}' body: '${{ steps.dotnet-code-metrics.outputs.summary-details }}' commit-message: 'docs: automated .NET code metrics update' - branch: dotnet-code-metrics-updates + branch: dotnet-code-metrics-updates + base: main # The badge lives on an orphan branch so README can link to a stable raw URL without # adding commit noise to main. From 943a1b0b646d04d21cf87e232184a9cb0355400f Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Fri, 16 Oct 2026 21:25:24 -0400 Subject: [PATCH 3/7] Update build-package.yaml to ignore markdown files Ignore markdown files in push and pull request workflows --- .github/workflows/build-package.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-package.yaml b/.github/workflows/build-package.yaml index c03058c..9e9655e 100644 --- a/.github/workflows/build-package.yaml +++ b/.github/workflows/build-package.yaml @@ -5,8 +5,12 @@ name: build-package on: push: branches: [main] + paths-ignore: + - '**.md' pull_request: branches: [main] + paths-ignore: + - '**.md' workflow_dispatch: # Superseded runs for the same branch are of no interest once a newer commit lands. From ecc4fe9073f030c9a11dd6d946d0494f06d5bd3e Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Fri, 16 Oct 2026 21:33:34 -0400 Subject: [PATCH 4/7] Refactor build-package.yaml for metrics generation Updated the workflow to generate and publish .NET code metrics. --- .github/workflows/build-package.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-package.yaml b/.github/workflows/build-package.yaml index 9e9655e..b67e269 100644 --- a/.github/workflows/build-package.yaml +++ b/.github/workflows/build-package.yaml @@ -84,7 +84,7 @@ jobs: - name: Verify packages run: ./scripts/verify-packages.sh - - name: generate stats + - name: Generate Metrics id: dotnet-code-metrics uses: dotnet/samples/github-actions/DotNet.GitHubAction@main with: @@ -102,6 +102,11 @@ jobs: commit-message: 'docs: automated .NET code metrics update' branch: dotnet-code-metrics-updates base: main + + - name: Publish Metrics to Job Summary + run: | + echo "### 📊 .NET Code Metrics Report" >> $GITHUB_STEP_SUMMARY + cat CODE_METRICS.md >> $GITHUB_STEP_SUMMARY # The badge lives on an orphan branch so README can link to a stable raw URL without # adding commit noise to main. From c51b57ef5d78ce05406aec3e3543f92662ec7227 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Fri, 16 Oct 2026 21:41:44 -0400 Subject: [PATCH 5/7] Improve metrics publishing in build workflow Enhance metrics report in job summary with additional details. --- .github/workflows/build-package.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-package.yaml b/.github/workflows/build-package.yaml index b67e269..4475606 100644 --- a/.github/workflows/build-package.yaml +++ b/.github/workflows/build-package.yaml @@ -106,7 +106,13 @@ jobs: - name: Publish Metrics to Job Summary run: | echo "### 📊 .NET Code Metrics Report" >> $GITHUB_STEP_SUMMARY - cat CODE_METRICS.md >> $GITHUB_STEP_SUMMARY + echo "${{ steps.dotnet-code-metrics.outputs.summary-title }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + # Using a multi-line HERE doc to safely handle markdown spacing + cat << 'EOF' >> $GITHUB_STEP_SUMMARY + ${{ steps.dotnet-code-metrics.outputs.summary-details }} + EOF # The badge lives on an orphan branch so README can link to a stable raw URL without # adding commit noise to main. From e81fd29ae0714e3601a8f07724c89c0d50b5f9e8 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Fri, 16 Oct 2026 21:51:24 -0400 Subject: [PATCH 6/7] Enhance metrics reporting in build-package workflow Updated the GitHub Actions workflow to include dynamic location of CODE_METRICS.md and improved error handling for missing metrics file. --- .github/workflows/build-package.yaml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-package.yaml b/.github/workflows/build-package.yaml index 4475606..5acd7c6 100644 --- a/.github/workflows/build-package.yaml +++ b/.github/workflows/build-package.yaml @@ -105,14 +105,17 @@ jobs: - name: Publish Metrics to Job Summary run: | - echo "### 📊 .NET Code Metrics Report" >> $GITHUB_STEP_SUMMARY - echo "${{ steps.dotnet-code-metrics.outputs.summary-title }}" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📊 Detailed .NET Code Metrics Report" >> $GITHUB_STEP_SUMMARY - # Using a multi-line HERE doc to safely handle markdown spacing - cat << 'EOF' >> $GITHUB_STEP_SUMMARY - ${{ steps.dotnet-code-metrics.outputs.summary-details }} - EOF + # Dynamically locate the CODE_METRICS.md file wherever it was generated + METRICS_FILE=$(find . -name "CODE_METRICS.md" | head -n 1) + + if [ -f "$METRICS_FILE" ]; then + echo "Found metrics file at: $METRICS_FILE" + cat "$METRICS_FILE" >> $GITHUB_STEP_SUMMARY + else + echo "❌ Error: Could not find the generated CODE_METRICS.md file in the workspace." >> $GITHUB_STEP_SUMMARY + fi # The badge lives on an orphan branch so README can link to a stable raw URL without # adding commit noise to main. From b1df6b29f64ef6c46b45b56d32273d1140d66376 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Fri, 16 Oct 2026 22:05:08 -0400 Subject: [PATCH 7/7] Update workflow to upload .NET metrics as artifact Replaced the step for publishing metrics to job summary with an artifact upload step for the .NET code metrics report. --- .github/workflows/build-package.yaml | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-package.yaml b/.github/workflows/build-package.yaml index 5acd7c6..e83b1e0 100644 --- a/.github/workflows/build-package.yaml +++ b/.github/workflows/build-package.yaml @@ -103,19 +103,13 @@ jobs: branch: dotnet-code-metrics-updates base: main - - name: Publish Metrics to Job Summary - run: | - echo "### 📊 Detailed .NET Code Metrics Report" >> $GITHUB_STEP_SUMMARY - - # Dynamically locate the CODE_METRICS.md file wherever it was generated - METRICS_FILE=$(find . -name "CODE_METRICS.md" | head -n 1) - - if [ -f "$METRICS_FILE" ]; then - echo "Found metrics file at: $METRICS_FILE" - cat "$METRICS_FILE" >> $GITHUB_STEP_SUMMARY - else - echo "❌ Error: Could not find the generated CODE_METRICS.md file in the workspace." >> $GITHUB_STEP_SUMMARY - fi + - name: Upload Metrics Artifact + uses: actions/upload-artifact@v4 + with: + name: dot-net-code-metrics-report + path: | + **/CODE_METRICS.md + retention-days: 14 # The badge lives on an orphan branch so README can link to a stable raw URL without # adding commit noise to main.