登录
首页 >  Golang >  Go问答

以程序代码方式在Heroku上进行部署

来源:stackoverflow

时间:2024-03-01 13:45:25 162浏览 收藏

哈喽!大家好,很高兴又见面了,我是golang学习网的一名作者,今天由我给大家带来一篇《以程序代码方式在Heroku上进行部署》,本文主要会讲到等等知识点,希望大家一起学习进步,也欢迎大家关注、点赞、收藏、转发! 下面就一起来看看吧!

问题内容

我正在寻找一些帮助,以编程方式将应用程序部署到 heroku。 heroku 有一个 cli 应用程序来管理您的应用程序。根据命令 heroku login 写入 ~/.netrc api 密钥:

machine api.heroku.com
  login [email protected]
  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 protected]",
            password: "6450sdf8-bd51-40da-9706-e39s85mc251f",
        },
    })
    if err != nil {
        log.fatal(err)
    }

并且有错误

2020/01/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;设置 +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 protected]'
> 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=

授权:基本ahjky29ka...mzk2mmjkzti1mwy=

是 base64 格式的 email:token。 为什么我无法使用 ~/.netrc 中的密钥成功进行身份验证?如何以编程方式推送到远程存储库?谢谢!


解决方案


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

machine api.heroku.com
  login [email protected]
  password 6450sdf8-bd51-40da-9706-e39s85mc251f
machine git.heroku.com
  login [email protected]
  password 6450sdf8-bd51-40da-9706-e39s85mc251f

以上就是《以程序代码方式在Heroku上进行部署》的详细内容,更多关于的资料请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>