我已经为 Github Action 编写了一个测试文件:
test.yml
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
but my 包.json使用组织私人存储库。当 Github Action 运行时,它失败并出现错误:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@org/repo/
npm ERR! 404
npm ERR! 404 '@org/[email protected] /cdn-cgi/l/email-protection' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-02-10T17_17_46_961Z-debug.log
Error: Process completed with exit code 1.
我的研究试图解决这个问题:
- 包未发布到 npm(不在 npm 注册表中) https://stackoverflow.com/questions/64589655/package-is-not-publishing-to-npm-not-in-the-npm-registry
- 尝试将新包发布到 NPM 时收到 404 https://stackoverflow.com/questions/39115101/getting-404-when-attempting-to-publish-new-package-to-npm
- 安装 npm 包失败并出现 404 https://stackoverflow.com/questions/47520181/installing-npm-package-fails-with-404
- 发布 npm 包时出现 404 错误 -npm ERR! 404 Not Found - PUT https://registry.npmjs.org/ https://stackoverflow.com/questions/69924422/404-error-while-publishing-npm-package-npm-err-404-not-found-put-https-r
在我的 Github Action 中,如何正确引用私有组织存储库,以便我的测试能够正常工作,或者是否缺少一个步骤?
This answer https://stackoverflow.com/a/71070686/1952287是正确的,这是示例test.yml现在归档:
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
- run: npm ci
- run: npm run build --if-present
- run: npm test
Github Action 显示为已通过:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)