如何在Github Action中使用yarn安装私有软件包? [英] How do I install private packages using yarn inside a Github Action?

查看:301
本文介绍了如何在Github Action中使用yarn安装私有软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前的工作流程:

name: Node CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x]

    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: npm install, build, and test
        run: |
          npm install yarn -g
          yarn
          yarn test
        env:
          CI: true
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

我已经在回购秘密区域中设置了我的NPM_TOKEN.

I have setup my NPM_TOKEN in the repo secrets area.

该令牌也在Netlify上使用,并且netlify构建过程正常工作.

The token is also in use on Netlify, and the netlify build process works.

运行此工作流程时,我的任何私有软件包都收到404.

When this workflow runs, I get a 404 for any of my private packages.

我在做什么错了?

推荐答案

找到了解决方法:

写出.npmrc作为作业的一部分,而不是依赖于env变量.

Write out .npmrc as part of the job instead of relying on an env variable.

name: Node CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x]

    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: npm install, build, and test
        run: |
          echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
          npm install yarn -g
          yarn
          yarn test
        env:
          CI: true

这篇关于如何在Github Action中使用yarn安装私有软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆