[ Day:29 ] GitHub Actions 懒人部署 - 如何安装多个来源的 npm package

情境,有一包公司内部的private-pkg,要安装才能 Build ,怎麽办QAQ

建立 .npmrc npm or Githib-pkg authToken 设定登入

档案: /.npmrc

//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
always-auth=true

建立 XXX.yml

档案:XXX.yml

    - name: Use Node.js
      uses: actions/setup-node@v1
      with:
        always-auth: true
        node-version: '12.x'
        registry-url: https://registry.npmjs.org #站点来源
        scope: '@你的组织&站点来源'
    - name: Install dependencies
      run: |
        npm install
            or 
        npm ci
        
    - name: Use Node.js 第二次
      uses: actions/setup-node@v1
      with:
        always-auth: true
        node-version: '12.x'
        registry-url: https://npm.pkg.github.com
        scope: '@你的组织&站点来源'
    - name: Install dependencies
      run: npm install @你的组织&站点来源/[email protected]
      env:
        NODE_AUTH_TOKEN: ${{secrets.MY_PAT_TOKEN}}

npm ci

https://ithelp.ithome.com.tw/upload/images/20201013/20104220P39e87Fh8C.png

npm cinpm install 的差异?

使用npm ci将版本安装在 package-lock.json or npm-shrinkwrap.json 文件中,并防止更新.lock文件。
使用 npm ci 速度通常比 npm install。 速度快

但是,不适用以上方法QQ,只能用 actions/cache@v2 (目前支援 Linux/macOS)

参考:https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-nodejs


<<:  Day 29 - 上架 App 到 Google Play Store for Android TV Part 2

>>:  Day28 D3js Diagram常见的两点浪漫路径

铁人赛 Day22 -- Bootstrap 格线系统

前言 今天看我们 Bootstrap 其他功能吧 一、基本语法 <div class=&quo...

[经典回顾]未知病毒入侵金融业事件纪录

防毒软件不断推陈出新,病毒也变化多端... 站在 Blueteam 位置,守住资讯安全防线的难度也飞...

[Day 22] Node Event loop 1

前言 昨天, 我们知道了 JS 层藉由 V8 引用 C++ 层, C++ 层又利用 AIO (非同步...

Kotlin Android 第19天,从 0 到 ML - RecyclerView 动态列表

前言: RecyclerView 可以轻松高效地显示大量数据。 RecyclerView回收这些单独...

Rails幼幼班--Rails安装Tailwindcss

用gem跟CDN不好吗... 这麽简单的事情也要分享?? 因为,没常安装就忘东忘西了... 认命做...