【问题标题】:how to access private github repos using yaml如何使用 yaml 访问私有 github 存储库
【发布时间】:2021-01-18 04:13:39
【问题描述】:

我正在尝试找到一种方法来通过我的 YAML 管道访问我的私有 github 存储库,该管道在 azure devops 中运行。我可以创建 PAT 访问令牌,但我需要复制此令牌并将其作为秘密值粘贴到 github -> repo -> settings -> secret 中吗?我将如何访问此令牌以访问我的 github 私人仓库?我有以下步骤,但不确定这是否有效:

steps:
  - shell: pwsh
    env:
      SUPER_SECRET: ${{ secrets.SuperSecret }}
    run: |
      example-command "$env:SUPER_SECRET"

访问我的 gihuh 存储库需要哪些 yaml 任务?我知道使用下面我可以访问公共存储库但不能访问私有存储库:

  repositories:
    - repository: myrepo
      endpoint: svc-github
      name: projecta/privaterepo
      type: github

对此有什么想法吗?谢谢。

【问题讨论】:

    标签: azure github azure-devops yaml azure-pipelines


    【解决方案1】:

    要使用 YAML 管道中的私有 github 存储库,您必须为其授予授权:

    • 转到 Azure DevOps 上的 Azure devOps 项目的设置
    • 选择“服务连接”
    • 您必须创建一个新的 GitHub 服务连接并授予对您的私有存储库的访问权限
    • 之后,指定在“endoint:”中创建的服务连接

    所以,你会得到类似的东西:

    resources:
      repositories:
      - repository: common
        type: github
        name: Contoso/CommonTools
        endpoint: [your service connection name]
    

    有关它的 Azure DevOps 文档部分:https://docs.microsoft.com/en-us/azure/devops/pipelines/process/resources?view=azure-devops&tabs=example#resources-repositories

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-23
      • 2013-08-17
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-23
      • 2023-03-16
      相关资源
      最近更新 更多