如何在 Heroku 上部署 Git LFS?

Ran*_*nga 6 github heroku node.js git-lfs

我在Node.js上完成了一个项目,该项目已经推送到GitHub,该项目有一个大于100MB的视频,需要Git LFS。Git LFS 成功推送到 GitHub,没有任何问题。

这个项目的第二阶段是在 Heroku 上托管,这就是我陷入困境的地方。我都尝试过:

heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
Run Code Online (Sandbox Code Playgroud)

heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
Run Code Online (Sandbox Code Playgroud)

当它被推送时使用

git push heroku master --no-verify
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

remote: -----> Git LFS app detected
remote: Env var BL_BUILDPACK_GIT_LFS_REPO is not set
remote:  !     Push rejected, failed to compile Git LFS app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to intense-journey-80070.
remote: 
To https://git.heroku.com/intense-journey-89070.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/intense-journey-89070.git'
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

Chr*_*ris 1

你说

heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
Run Code Online (Sandbox Code Playgroud)

但您不应该在此处使用您的应用程序名称。我猜你想使用这个构建包?在这种情况下,你应该字面意义上做

heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
Run Code Online (Sandbox Code Playgroud)

您还收到一条错误消息:

Env var BL_BUILDPACK_GIT_LFS_REPO is not set
Run Code Online (Sandbox Code Playgroud)

构建包需要一些额外的配置,如 Heroku 上的构建包页面所述,但您似乎尚未完成:

为您的应用程序设置以下环境变量:

  • BL_BUILDPACK_GIT_LFS_REPO到存储库的克隆 URL,从中下载 Git LFS 资产。这应包括非交互式克隆所需的任何用户名、密码或个人访问令牌。有关语法的详细信息,请参阅此处。它一定是类似的东西git@github.com:BureauxLocaux/my-repo
  • BL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY:您的私钥以 base64 编码,后缀为base64 -w 0. 您可以使用heroku config:set --app preprod-bureauxlocaux "BL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY=$(cat ~/.ssh/heroku_deploy_lfs | base64 -w 0)"它来设置它。

私人 SSH 密钥应该受到近乎偏执的保护,因此请确保使用用于部署此存储库的专用 SSH 密钥。为该部署密钥授予尽可能最低级别的权限。