Skip to content
Merged
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
45 changes: 43 additions & 2 deletions .github/workflows/dotnet-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
env:
DEFAULT_DOTNET_VERSION: "8.0.x"

permissions:
contents: read
pull-requests: read

jobs:
build:
strategy:
Expand Down Expand Up @@ -98,10 +102,13 @@ jobs:
${{ github.workspace }}/packages/**/*.nupkg

publish-nuget:
needs: sign
needs: [sign, detect-pr-label]
runs-on: ubuntu-latest
environment:
name: nuget-beta
# Only run publish when the merged PR does NOT contain the skip label.
# The label name is configurable via the `SKIP_PUBLISH_LABEL` env in the detector job below.
if: needs.detect-pr-label.outputs.skip_publish != 'true'
steps:
- name: Download package
uses: actions/download-artifact@v5
Expand All @@ -112,10 +119,12 @@ jobs:
run: dotnet nuget push ./*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_PACKAGE_PUSH_TOKEN }}

publish-azure-artifacts:
needs: sign
needs: [sign, detect-pr-label]
runs-on: windows-latest
environment:
name: azure-artifacts
# Skip pushing to Azure Artifacts when the merged PR requested skipping the publish.
if: needs.detect-pr-label.outputs.skip_publish != 'true'
steps:
- name: Download package
uses: actions/download-artifact@v5
Expand Down Expand Up @@ -144,3 +153,35 @@ jobs:
uses: ./.github/workflows/code-coverage.yml
secrets: inherit

detect-pr-label:
# This job detects whether the commit that triggered this push
# is associated with a merged pull request that contains a label
# indicating we should skip publishing packages.
runs-on: ubuntu-latest
outputs:
skip_publish: ${{ steps.check.outputs.skip }}
env:
# Change this label name to whatever you use to skip publishing.
SKIP_PUBLISH_LABEL: skip-nuget-publish
steps:
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing step name before the id field. GitHub Actions requires a name field or the step will use a default name. Add - name: Check for skip label before the id field.

Note: See the diff below for a potential fix:

@@ -164,6 +164,7 @@
       # Change this label name to whatever you use to skip publishing.
       SKIP_PUBLISH_LABEL: skip-nuget-publish
     steps:
+        name: Check for skip label
         id: check
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Copilot uses AI. Check for mistakes.
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LABEL="${SKIP_PUBLISH_LABEL}"
# Get the first PR associated with this commit (if any)
number=$(gh api -H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" --jq '.[0].number' 2>/dev/null || echo "")
if [ -z "$number" ] || [ "$number" = "null" ]; then
# No PR found for this commit -> do not skip by default
echo "skip=false" >> $GITHUB_OUTPUT
exit 0
fi

# List label names for the PR and check for an exact match
has_label=$(gh api "/repos/${{ github.repository }}/issues/$number/labels" --jq '.[].name' 2>/dev/null | grep -Fx -- "$LABEL" || true)
if [ -n "$has_label" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
Loading