在 GitHub 上使用 Composer 和 Private Repository 在 Build Server 上使用 VCS

2022-01-21 00:00:00 ssh git github php composer-php

我的 compsoser.json 使用我们组织 Github 帐户中的 2 个私有存储库,如下所示.

My compsoser.json uses 2 private repositories from our Organisation Github Account and is as follows.

{
    "name": "API",
    "repositories": [
      {
        "type": "vcs",
        "url": "git@github.com/company/private.git"
      },
      {
        "type": "vcs",
        "url": "git@github.com/company/private2.git"
      }
    ],
    "require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": ">2.1.3",
        "doctrine/mongodb-odm": "dev-master",
        "doctrine/doctrine-mongo-odm-module": "dev-master",
        "company/private": "dev-master",
        "company/private2": "dev-master"
    }
}

我们已经设置了 SSH 密钥并将它们添加到我们登台服务器上的授权密钥中.当我们运行 git clone 时,它​​可以完美运行,并且不需要任何凭据.

We've setup SSH keys and added them to the authorized keys on our staging server. When we run git clone it works perfectly and isn't asking for any credentials.

但是,当我们运行 composer update 时,由于 composer 无权访问存储库,因此获取存储库失败.

However, when we run composer update the fetching of the repositories fails because composer doesn't have access to the repositories.

由于这是以非交互方式运行的,因为这是构建脚本的一部分,因此我们无法输入凭据并希望将其自动化.

Since this is ran in a non-interactive way as this is part of a build script we can't enter credentials and like to have this automated.

我们可以做些什么来让 composer 在构建过程中访问我们的私有仓库?

What can we do to let composer have access to our private repo's during the build?

推荐答案

您可以配置composer使用密钥文件访问私有仓库.

You can configure composer to use key files to access private repository.

更多信息:https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md#security

相关文章