Skip to content

Npm publish - secrets.GITHUB_TOKEN not used because .npmrc exists #25414

Discussion options

You must be logged in to vote

@elexisvenator,

You can try to use the sed command to replace the token with the GITHUB_TOKEN in the .npmrc file, before executing the publish step. Here you also may need using regular expression in the sed command.
A simple example as reference:

- name: replace token
  run: echo "$(sed 's/\(_authToken=\)[a-z0-9]*\($\)/\1${{ env.GITHUB_TOKEN }}\2/g' .npmrc)" > .npmrc
  env:
    GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Packages Host your dependencies, libraries, and production-ready code, right from your repository Question
3 participants