npm / npm/documentation

[QUESTION] Trusted Publishing with re-usable GitHub Workflows

Open
#1,755 7 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
MDX
Stars
711
Forks
4.2k
Avg merge
4d 16h
Merged PRs (30d)
3

Description

Hey everyone!

I have a question regarding Trusted Publishers that from reading the docs doesn't seem very clear to me.

We have some repositories that have multiple GitHub actions for publishing packages to npm, one to dev tag, one to next, one to latest (and a few others). These workflows all consume a re-usable workflow, where the call to npm publish actually takes place.

Per the last paragraph in Troubleshooting section

Some GitHub Actions workflows use workflow_call to invoke other workflows that run npm publish, or use workflow_dispatch for manual publishing. When this happens, validation checks the calling workflow's name instead of the workflow that actually contains the publish command, which can cause configuration mismatches.

So I am confused as to how can we use trusted publishing when we have a setup like:

  • workflow_a.yml
  • workflow_b.yml
  • workflow_c.yml

That all call workflow_reusable.yml (workflow_call), without changing the setup of the workflows?

So far I've been only able to get it working if I set the GitHub Workflow file in npm settings as one of the specific a,b,c workflows, and paste the reusable code inside the calling workflow.

Would I need to always use a single Github Actions workflow file to enable trusted publishing?

Let me know if you need me to clarify anything.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the Trusted Publishers troubleshooting section linked in the issue, then compare its guidance with the workflow_a.yml, workflow_b.yml, workflow_c.yml, and workflow_reusable.yml setup described. Clarify the supported reusable-workflow configuration and document what users must configure or change for trusted publishing to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.