在构建服务器上使用 VCS 在 GitHub 上使用 Composer 和私有存储库

2021-12-23 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

相关文章