以编程方式部署到Heroku

kyxcudwk  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(107)

我正在寻找一些帮助编程部署应用程序到Heroku。Heroku有一个cli应用程序管理您的应用程序。在命令heroku login写入到~/.netrc API密钥:

machine api.heroku.com
  login email@gmail.com
  password 6450sdf8-bd51-40da-9706-e39s85mc251f

在文档中,我可以找到https://devcenter.heroku.com/articles/git#http-git-authentication
Heroku HTTP Git终结点仅接受基于API密钥的HTTP基本身份验证。不需要用户名,并且忽略为用户名传递的任何值。
我的代码使用https://github.com/src-d/go-git

r, err := git.PlainOpen("go-getting-started")
    if err != nil {
        log.Fatal(err)
    }
    r.CreateRemote(&config.RemoteConfig{
        Name: "heroku",
        URLs: []string{"https://git.heroku.com/afternoon-ocean-91922.git"},
    })

    err = r.Push(&git.PushOptions{
        Auth: &http.BasicAuth{
            Username: "email@gmail.com",
            Password: "6450sdf8-bd51-40da-9706-e39s85mc251f",
        },
    })
    if err != nil {
        log.Fatal(err)
    }

并有误差
2020年1月30日17:38:23需要身份验证
退出状态1
好的,那么我set -i; GIT_TRACE=2 GIT_CURL_VERBOSE=2 GIT_TRACE_PERFORMANCE=2 GIT_TRACE_PACK_ACCESS=2 GIT_TRACE_PACKET=2 GIT_TRACE_PACKFILE=2 GIT_TRACE_SETUP=2 GIT_TRACE_SHALLOW=2 git push heroku master -v -v; set +i,在日志中看到这行

Host: git.heroku.com
User-Agent: git/2.25.0
Accept: */*
Accept-Encoding: deflate, gzip
Accept-Language: ru-RU, *;q=0.9
Pragma: no-cache

* Mark bundle as not supporting multiuse
< HTTP/1.1 401 Unauthorized
< Content-Type: text/plain
< Date: Thu, 30 Jan 2020 15:00:44 GMT
< Request-Id: c0786480-055d-40bc-90b3-d795304c2777
< Server: endosome/development (instance=6283027; pid=4272)
< Www-Authenticate: Basic realm="Heroku"
< Content-Length: 249
< Connection: keep-alive
< 
* Ignoring the response-body
* Connection #0 to host git.heroku.com left intact
* Issue another request to this URL: 'https://git.heroku.com/infinite-garden-93715.git/info/refs?service=git-receive-pack'
* Found bundle for host git.heroku.com: 0x5616ad25b0a0 [serially]
* Can not multiplex, even if we wanted to!
* Re-using existing connection! (#0) with host git.heroku.com
* Connected to git.heroku.com (54.225.111.180) port 443 (#0)
* Server auth using Basic with user 'email@gmail.com'
> GET /infinite-garden-93715.git/info/refs?service=git-receive-pack HTTP/1.1
Host: git.heroku.com
Authorization: Basic aHJkY29ka...Mzk2MmJkZTI1MWY=
User-Agent: git/2.25.0
Accept: */*
Accept-Encoding: deflate, gzip
Accept-Language: ru-RU, *;q=0.9
Pragma: no-cache

线aHJkY29ka...Mzk2MmJkZTI1MWY= in
授权人:基本值=
在base64中是email:token。为什么我不能用~/.netrc中的密钥成功认证?我如何编程推送到远程仓库?谢谢!

tez616oj

tez616oj1#

要将git部署到Heroku,除了www.example.com凭据之外,.netrc文件还应包含git.heroku.com登录凭据api.heroku.com

machine api.heroku.com
  login email@gmail.com
  password 6450sdf8-bd51-40da-9706-e39s85mc251f
machine git.heroku.com
  login email@gmail.com
  password 6450sdf8-bd51-40da-9706-e39s85mc251f

相关问题