使用yarn.lock在Github Actions上使用yarn安装私有Github包未获得授权

Ale*_*lec 7 yarnpkg github-actions github-package-registry

类似的问题已经有很多:

然而,我们的问题似乎有所不同,因为:

  • yarn install在本地机器上运行良好
  • 仅当使用 Github Actions 时才会出现此问题
  • yarn install 如果我们删除,GH Actions就会成功yarn.lock

以前有人遇到过这个吗?特别是它不能处理文件yarn.lock

如果重要的话,设置如下:

build.yml

    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v1
      with:
        node-version: '10.x'
        registry-url: 'https://npm.pkg.github.com'
    - name: Install
      run: yarn install
      env:
        # GITHUB_TOKEN can't access packages hosted in private repos,
        # even within the same organisation
        NODE_AUTH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
    - name: Build
      run: yarn build
    - name: Test
      run: yarn test --forbid-only
Run Code Online (Sandbox Code Playgroud)

我们还有一个.npmrc用于本地安装的文件:

@<org>:registry=https://npm.pkg.github.com
Run Code Online (Sandbox Code Playgroud)

没有 .yarnrc文件。

Ale*_*lec 0

.npmrc我们通过在配置中显式复制配置来解决这个问题build.yml

      - uses: actions/setup-node@v1
        with:
          node-version: '10.x'
          registry-url: 'https://npm.pkg.github.com'
          # These following two lines are the key:
          always-auth: true
          scope: '@reedsy'
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

7961 次

最近记录:

4 年,7 月 前