在bitrise中使用github令牌访问npm.pkg.github.com

发布于 2025-02-02 18:59:25 字数 2816 浏览 3 评论 0原文

我在构建CICD和用比特里斯方面很陌生。目前,我正在尝试为使用React Native的混合移动应用程序创建一个CICD。我几乎已经完成了它,但是在CICD期间运行纱线安装时有错误。错误是

错误发生意外错误: “ https://npm.pkg.github.com/download/@someorg/abc-app/1.2.28/f479287e129b6ce227c1c1c1c1c1c1c1ecda507f25a9bcac02abcac024bcac024bcac024b327f2865c865c87a ausept

此错误是由于我的代码回购根中的.npmrc文件造成的,我的问题

@someorg=https://npm.pkg.github.com/
always-auth=true

现在是我的问题,我的问题是我如何告诉bitrise cicd从npm.pkg.github.com下载时使用我的github令牌。我已经根据我的github代币的价值创建了一个保密,但是在哪里可以在bitrise.yml中使用它来解决此问题。以下是bitrise.yml文件。谢谢


format_version: '11'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: react-native
workflows:
  deploy:
    description: |
      Tests, builds and deploys the app using *Deploy to bitrise.io* Step.

      Next steps:
      - Set up an [Apple service with API key]
      - Check out [Getting started with React Native apps]
    steps:
    - activate-ssh-key@4: {}
    - git-clone@6: {}
    - yarn@0:
        inputs:
        - workdir: "$WORKDIR"
        - command: install
    - yarn@0:
        inputs:
        - workdir: "$WORKDIR"
        - command: test
    - install-missing-android-tools@3:
        inputs:
        - gradlew_path: "$PROJECT_LOCATION/gradlew"
    - android-build@1:
        inputs:
        - project_location: "$PROJECT_LOCATION"
        - module: "$MODULE"
        - variant: "$VARIANT"
    - cocoapods-install@2: {}
    - xcode-archive@4:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
        - scheme: "$BITRISE_SCHEME"
        - distribution_method: "$BITRISE_DISTRIBUTION_METHOD"
        - configuration: Release
        - automatic_code_signing: api-key
    - deploy-to-bitrise-io@2: {}
  primary:
    description: |
      Runs tests.

      Next steps:
      - Check out [Getting started with React Native apps].
    steps:
    - activate-ssh-key@4: {}
    - authenticate-with-github-oauth@0:
        inputs:
        - access_token: "$pstoken"
        - username: "$gituser"
    - git-clone@6: {}
    - yarn@0:
        inputs:
        - workdir: "$WORKDIR"
        - command: install
    - yarn@0:
        inputs:
        - workdir: "$WORKDIR"
        - command: test
    - deploy-to-bitrise-io@2: {}
meta:
  bitrise.io:
    stack: osx-xcode-13.2.x
    machine_type_id: g2.4core
app:
  envs:
  - opts:
      is_expand: false
    WORKDIR: "."
  - opts:
      is_expand: false
    PROJECT_LOCATION: android
  - opts:
      is_expand: false
    MODULE: app
  - opts:
      is_expand: false
    VARIANT: Debug
  - opts:
      is_expand: false
    BITRISE_PROJECT_PATH: ios/some_mobile.xcworkspace
  - opts:
      is_expand: false
    BITRISE_SCHEME: some_mobile
  - opts:
      is_expand: false
    BITRISE_DISTRIBUTION_METHOD: ad-hoc

I am quite new in building cicd and with bitrise. Currently I am trying to create a cicd for hybrid mobile app which is using react native. I have almost completed it but having an error when running yarn install during cicd. The error is

error An unexpected error occurred:
"https://npm.pkg.github.com/download/@someorg/abc-app/1.2.28/f479287e129b6ce227c1c1ecda507f3ecf25a9bcac024b327f2865c87a14df73: Request failed "401 Unauthorized"".

This error is due to .npmrc file in the root of my code repo, the content inside .npmrc is

@someorg=https://npm.pkg.github.com/
always-auth=true

Now my question is how can I tell bitrise cicd to use my github token when downloading from npm.pkg.github.com. I have create a secrect in bitrise with the value of my github token but where can I use that in bitrise.yml to resolve this issue. Below is the bitrise.yml file. Thanks


format_version: '11'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: react-native
workflows:
  deploy:
    description: |
      Tests, builds and deploys the app using *Deploy to bitrise.io* Step.

      Next steps:
      - Set up an [Apple service with API key]
      - Check out [Getting started with React Native apps]
    steps:
    - activate-ssh-key@4: {}
    - git-clone@6: {}
    - yarn@0:
        inputs:
        - workdir: "$WORKDIR"
        - command: install
    - yarn@0:
        inputs:
        - workdir: "$WORKDIR"
        - command: test
    - install-missing-android-tools@3:
        inputs:
        - gradlew_path: "$PROJECT_LOCATION/gradlew"
    - android-build@1:
        inputs:
        - project_location: "$PROJECT_LOCATION"
        - module: "$MODULE"
        - variant: "$VARIANT"
    - cocoapods-install@2: {}
    - xcode-archive@4:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
        - scheme: "$BITRISE_SCHEME"
        - distribution_method: "$BITRISE_DISTRIBUTION_METHOD"
        - configuration: Release
        - automatic_code_signing: api-key
    - deploy-to-bitrise-io@2: {}
  primary:
    description: |
      Runs tests.

      Next steps:
      - Check out [Getting started with React Native apps].
    steps:
    - activate-ssh-key@4: {}
    - authenticate-with-github-oauth@0:
        inputs:
        - access_token: "$pstoken"
        - username: "$gituser"
    - git-clone@6: {}
    - yarn@0:
        inputs:
        - workdir: "$WORKDIR"
        - command: install
    - yarn@0:
        inputs:
        - workdir: "$WORKDIR"
        - command: test
    - deploy-to-bitrise-io@2: {}
meta:
  bitrise.io:
    stack: osx-xcode-13.2.x
    machine_type_id: g2.4core
app:
  envs:
  - opts:
      is_expand: false
    WORKDIR: "."
  - opts:
      is_expand: false
    PROJECT_LOCATION: android
  - opts:
      is_expand: false
    MODULE: app
  - opts:
      is_expand: false
    VARIANT: Debug
  - opts:
      is_expand: false
    BITRISE_PROJECT_PATH: ios/some_mobile.xcworkspace
  - opts:
      is_expand: false
    BITRISE_SCHEME: some_mobile
  - opts:
      is_expand: false
    BITRISE_DISTRIBUTION_METHOD: ad-hoc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文