npm - 登录 MyGet 以获取 GitHub Actions 以安装 Private 包
问题描述
我正在尝试设置一个 GitHub Actions 工作流程,该工作流程将在创建 PR 时为项目运行测试。这是该操作的 YAML;这真的很简单。
steps:
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://www.myget.org/F/hsa/npm/
scope: '@hsa'
env:
NODE_AUTH_TOKEN: ${{ secrets.MYGET_TOKEN }}
- name: set always auth
run: |
npm config set always-auth true
- name: Install
run: |
npm install
- name: Run lint
shell: bash
run: |
if [[ $GITHUB_BASE_REF ]]
then
export NX_BASE=remotes/origin/$GITHUB_BASE_REF
else
export NX_BASE=$(git rev-parse HEAD~1)
fi
echo "Base => $NX_BASE"
npm run affected:test -- --base=$NX_BASE
“使用 Node.js” 步骤设置@hsa
范围的注册表 URL;这MYGET_TOKEN
是使用回购的秘密设置的。“set always auth”步骤是必要的,因为它不是自动完成的。这似乎足以允许安装私有包的操作,但它不起作用。这是我在“安装”步骤中遇到的错误:
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="MyGet - hsa"
我已经输出了.npmrc
在 Action 中创建的临时文件,它看起来确实正确,为给定范围设置了注册表,所以一切都应该工作。但是我无法通过 NPM 安装步骤来实际运行测试。
对于我在身份验证方面缺少的任何帮助,我们将不胜感激。谢谢!
解决方案
来自https://github.com/actions/setup-node/
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '10.x'
registry-url: 'https://registry.npmjs.org'
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
- run: npm install --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# `npm rebuild` will run all those post-install scripts for us.
- run: npm rebuild && npm run prepare --if-present
尝试在操作/设置节点中使用 npm install。
推荐阅读
- html - 收缩时弹性项目的位置高于其他弹性项目
- android - 使用 Firebase 身份验证的电子邮件 firebase 无法正常运行?
- c++ - 保存到静态类时 WIFI 名称 (char*) 行为异常
- unity3d - 图层蒙版问题 - 即使图层蒙版已更改,玩家仍会与敌人发生碰撞(Unity、Bolt 脚本)
- python - Heroku 无法识别 Procfile
- arduino - 用arduino控制360度伺服
- javascript - 如何找到执行 eval 代码的 [content] 脚本
- r - R:如何根据 R 中另一行的值扩展一行中的值?
- html - 当html代码不直接包含选项时如何使一个按钮默认单选按钮
- axapta - Microsoft Dynamics ax 2012 如何从 2 个不同的表创建自动查找