从子文件夹自动部署heroku [英] Automated heroku deploy from subfolder

查看:130
本文介绍了从子文件夹自动部署heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以从github自动部署到heroku,但是我还没有找到一种仅将子文件夹从github推送到heroku的方法.

I know you can deploy automatically to heroku from github, but I haven't found a way to only push a subfolder from github to heroku.

在命令行中,我知道可以执行以下操作:

From the command-line I know it is possible to do this with:

git subtree push --prefix <subfolder> heroku master

但是,我想知道是否有一种方法可以将github集成与heroku结合使用,以使其在将提交添加到分支时自动拉出特定的子文件夹.

However, I would like to know if there is a way to use the github integration with heroku to make it pull a specific subfolder automatically when a commit is added to a branch.

推荐答案

2018更新!要使用heroku启用自动部署,您需要对github具有 admin 访问权限您想部署的仓库.

2018 Update! To enable automated deployments with heroku, you need to have admin access for the github repo you want to deploy.

在Deploy选项卡中,滚动到Deployment方法并连接您的Github帐户.找到仓库并点击连接.现在应该在您的github中将heroku授权为Oauth应用.

Inside the Deploy tab, scroll to Deployment method and connect your Github account. find the repo and hit connect. heroku should be authorized as an Oauth app in your github now.

如果找不到存储库: 或者您的github未授权Heroku,或者您没有创建此存储库,需要确保您具有对该存储库的管理员访问权限.如果无法做到这一点,请通过访问Heroku仪表板中的访问"选项卡并将该管理员添加为协作者来邀请回购的管理员加入您的heroku应用程序.然后,管理员登录到heroku并在此处完成步骤1.然后,您可以完成以下步骤.

If you cannot find the repo: Either your github has not authorized Heroku or you did not create this repo and need to make sure you have admin access to it. If this is not possible, invite an admin of the repo to your heroku app by going to Access tab in Heroku Dashboard and adding the admin as a collaborator. The admin then logs into heroku and completes Step 1 here. Afterwards you can finish the following steps.

在设置"标签中,设置一个配置变量,以告知Heroku查找要部署的服务器代码的路径.

Inside the Settings tab, set a config var to tell Heroku the path to find the server code you want deployed.

示例:假设您的存储库名称为MyRepo,它有2个子文件夹. back-end包含一个Node.js服务器,而front-end包含一个React应用程序.您的github目录如下所示:

Example: lets say your repo name is MyRepo and it has 2 sub-folders. back-end contains a Node.js server and front-end contains a React app. Your github directory looks like this:

MyRepo/front-end/package.json MyRepo/back-end/package.json

MyRepo/front-end/package.json MyRepo/back-end/package.json

然后,应在左侧框中将config var设置为PROJECT_PATH,在右侧框中将back-end设置为.

Then you should set your config var to PROJECT_PATH in the left box and back-end in the right box.

再次在设置"选项卡中,您需要添加一个Buildpack,它将告诉heroku查找您的文件夹而不是部署回购根目录.那里应该已经有1个buildpack来告诉heroku它是什么类型的服务器(javascript/node.js,python/django等).

Again inside the Settings tab, you need to add a Buildpack that will tell heroku to look for your folder instead of deploying the repo root. There should already be 1 buildpack there to tell heroku what type of server it is (javascript/node.js, python/django, etc...).

输入此URL以添加buildpack https://github.com/timanovsky/subdir- heroku-buildpack.git 确保它在buildpack链的顶部(拖动左侧的行使其位于您添加的任何其他buildpack之上.

Enter this url to add buildpack https://github.com/timanovsky/subdir-heroku-buildpack.git and make sure this is at the top of the buildpack chain (drag the lines on the left to make it above any other buildpacks you have added.

在部署"选项卡中,滚动到自动部署",然后单击黑色按钮以启用自动部署

Inside the Deploy tab, scroll to Automatic Deploys and click the black button to enable automatic deploys

这篇关于从子文件夹自动部署heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆