以程序代码方式在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学习网公众号!
-
502 收藏
-
502 收藏
-
501 收藏
-
501 收藏
-
501 收藏
-
139 收藏
-
204 收藏
-
325 收藏
-
477 收藏
-
486 收藏
-
439 收藏
-
357 收藏
-
352 收藏
-
101 收藏
-
440 收藏
-
212 收藏
-
143 收藏
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 立即学习 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 立即学习 508次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 立即学习 497次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 立即学习 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 立即学习 484次学习