admin管理员组文章数量:1123087
I am using .npmrc to specify the registry and install it other projects, but as .npmrc is git ignored, how can I do this automatically at the time of deployment
I want to know what to do
Can you please share resources I can follow through
I am using .npmrc to specify the registry and install it other projects, but as .npmrc is git ignored, how can I do this automatically at the time of deployment
I want to know what to do
Can you please share resources I can follow through
Share Improve this question asked 4 hours ago HatakeKakashiHatakeKakashi 11 bronze badge 1- Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Bot Commented 4 hours ago
1 Answer
Reset to default 1I've come across similar situations in the past, and I would usually either do one of these:
- Put the entire contents of the
.npmrc
file into a GitHub actions secret, then print it to a new.npmrc
file in your action. - Store the token and other info as a secret, then create a new
.npmrc
file and inject the secrets into the file.
If you were to go the second route, you would probably have something like this in your GitHub actions workflow:
# ...
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Publish
run: |
# These use the variables defined in step's env
echo "registry=${NPM_REGISTRY}" > .npmrc
echo "registry/:_authToken=${NPM_TOKEN}" >> .npmrc
npm publish
env: # Secrets from GitHub are injected below
NPM_REGISTRY: ${{ secrets.NPM_REGISTRY }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
In your GitHub repository, define NPM_REGISTRY and NPM_TOKEN as secrets (docs) by going to Settings > Security > Actions > Secrets.
Resources
- https://docs.npmjs.com/cli/v8/configuring-npm/npmrc
- https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions
- https://andreas-sommarstrom.medium.com/installing-packages-from-private-npm-registry-with-github-actions-61d4f6328a91
版权声明:本文标题:javascript - I am using GitHub workflow action to publish a package when ever I push to main - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736547508a1944468.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论