Skip to content

Organization Packages Policy couldn't found when using Reusable Workflow #6

@guitarrapc

Description

@guitarrapc

Summary

When executing NuGet/login with a combination of NuGet Organization's package policy & Reusable workflow, it fails with a 401 error and the following message:

Error: Token exchange failed (401): No matching trust policy owned by user '***' was found.

Reproduce step

  1. Login to NuGet with Organization's administrator (my-nuget-user)
  2. Create Trusted Publishing Policy for Organization Package.
Policy Name: Foo
Package Owner: NuGet Organization Name (Foo-Org)
Repository Owner: GitHub Org Name (Foo-Org)
Repository: SampleRepo
Workflow File: release.yaml
  1. Create Reusable workflow at repo Foo-Org/ReusableRepo
name: Build-Release

on:
  workflow_call:

jobs:
  create-release:
    permissions:
      contents: write
      id-token: write # required for NuGet Trusted Publish
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    steps:
      - name: NuGet login (OIDC → temp API key)
        uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1.1.0
        id: login
        with:
          user: my-nuget-user
      # omit...
  1. Create release.yaml in Foo-Org/SampleRepo repository and set following github action with permissions.id-token: write
name: Build-Release

jobs:
  dummy:
    permissions:
      contents: write
      id-token: write # required for NuGet Trusted Publish
    uses: Foo-Org/ReusableRepo/.github/workflows/release.yaml@main
  1. Execute Actions, and failed.
Error: Token exchange failed (401): No matching trust policy owned by user '***' was found.

Remarks

If workflow is not reusable workflow, it works without issue.

name: Build-Release

jobs:
  dummy:
    permissions:
      contents: write
      id-token: write # required for NuGet Trusted Publish
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    steps:
    # my-nuget-user has policy for Organization package
    - name: NuGet login
      uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1.1.0
      id: login
      with:
        user: my-nuget-user

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions