如何在circleCI配置中添加GitHub身份验证信息以进行程序包发布?

问题描述 投票:0回答:1

我正在我的仓库中为CircleCI设置config.yml文件,以便将其发布为GitHub NPM软件包。

[运行npm publish命令之前,我们需要使用用户名,密码(个人访问令牌)和电子邮件在GitHub NPM注册表上进行身份验证。

我已将它们存储为环境变量,可以使用$ {PACKAGE_PAT},$ {PACKAGE_ACCOUNT}和$ {PACKAGE_EMAIL}进行调用。

因此,现在我对如何在此过程中添加这些信息有0条线索,对此,我将非常感谢(第一次使用CI)。

这是我到目前为止设置的配置文件:

version: 2.1

executors:
  my-executor:
    docker:
      - image: circleci/node:10-browsers
    working_directory: ~/repo

jobs:
  build:
    executor: my-executor
    steps:
      - checkout
      - restore_cache:
          key: repo-{{ .Branch }}-{{ checksum "package-lock.json" }}
      - save_cache:
          key: repo-{{ .Branch }}-{{ checksum "package-lock.json" }}
          paths:
            - 'node_modules'
      - run: npm install
      - run: npm run build
      - run: npm login --registry=https://npm.pkg.github.com/
      - run: npm publish
workflows:
  version: 2
  auto_package_workflow:
    jobs:
      - build:
          filters:
            branches:
              only:
                - /feature\/FRON-1144.*/ 
github continuous-integration circleci npm-publish github-package-registry
1个回答
0
投票

我检查并遵循了npm注册表的文档,并按如下所示设置我的配置。不需要用户名和电子邮件。这很好用。

      - run:
          name: Publish to GitHub Packages
          command: |
            npm set //npm.pkg.github.com/:_authToken=${GITHUB_PACKAGE_PAT}
            npm publish
© www.soinside.com 2019 - 2024. All rights reserved.