How to deploy Git LFS on Heroku? - node.js

I have completed a project on Node.js which has already pushed into GitHub, this project has a video which larger than 100MB which required Git LFS. Git LFS successfully pushed into the GitHub no issue at all.
The second phase of this project is to host in Heroku, this is where I got stuck. I tried both:
heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
and
heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
When it's pushed using
git push heroku master --no-verify
I get the following error:
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'
How can I make this work?

You say
heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
but you shouldn't use your app name here. I guess you want to use this buildpack? In that case, you should literally do
heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
You also have an error message saying
Env var BL_BUILDPACK_GIT_LFS_REPO is not set
There is some additional configuration required for the buildpack, as outlined in its buildpack page on Heroku, which you appear not to have done:
Set the following environment variable for your app:
BL_BUILDPACK_GIT_LFS_REPO to the clone URL of the repository from which to download Git LFS assets. This should include any username, password, or personal access token which is necessary to clone noninteractively. See here for details on the syntax. It must be something like git#github.com:BureauxLocaux/my-repo
BL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY: your private key encoded in base64 with base64 -w 0. You can use heroku config:set --app preprod-bureauxlocaux "BL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY=$(cat ~/.ssh/heroku_deploy_lfs | base64 -w 0)" to set it.
Private SSH keys should be protected bordering on paranoia, so make sure to use a dedicated SSH key that is only used for deployment of this repository. Give that deploy key the lowest level of permission that you can.

The files that are linked to Large File System (LFS) are not supported in Heroku.
So you need to move to settings on heroku to add configs vars as key “HEROKU_BUILDPACK_GIT_LFS_REPO” to value “https://#github.com//repository.git” token is a unique personal Access token.
You need to register for that in your GitHub > settings> Developer Settings for Heroku to access your LFS files and also link in buildpacks to install LFS “https://github.com/raxod502/heroku-buildpack-git-lfs.git”.
Lastly, hit the deploy button in the deploy section and you are done with your project and available for people accessing over the internet.

Unfortunately Heroku doesn’t support git LFS at the moment.
Heroku doesn’t support git lfs. Using this method can cause pushes to fail.
https://devcenter.heroku.com/articles/git#deploy-from-a-branch-besides-main

Basically you can simply follow the instruction in this post. What I need to say is that when you register GitHub app, the URL you need to fill in "Webhook URL" and "Homepage URL" is both the URL you created using heroku (Example format: https://<app-name>.herokuapp.com).

Related

Change "View merge request for $branch" post push message in Gitlab

Using a self hosted gitlab instance, how can I modify this message that I get after pushing to the repository, on my git client side ?
git push
[...]
remote:
remote: View merge request for MYBRANCH:
remote: https://GITLAB_MR.URL
remote:
I tried checking the server side hooks of my omnibus installation in
/var/opt/gitlab/git-data/repositories/#hashed/MY_REPO_HASH
But I cant find any hook with this message there using grep -Hrn "View merge request"
Is this message not from a git hook ? How to configure it ?
If I cannot change it without modifying Gitlab's code, how can I add text there for pushers to read ?
As pointed out, this can only be done by modifying Gitlab's code and not by user configuration as of today.
I found the source of the message here : https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/internal_post_receive/response.rb
Of course most users wouldn't find this solution pratical.

Beginning with Heroku. Problem with authetication

I'm noob in git/heroku etc. I work according to the tutorial https://devcenter.heroku.com/articles/getting-started-with-nodejs#deploy-the-app .
I run commands in cmd:
heroku login
cd node-js-getting-started
heroku create (runned in past)
heroku auth:token
git push heroku master
After last command possibly window show where I put username "" and password heroku token that I get.
But after, this is displayed:
C:\Users\Administrátor\node-js-getting-started>git push heroku master
git: 'credential-managerd' is not a git command. See 'git --help'.
The most similar command is
credential-manager
remote: ! WARNING:
remote: ! Do not authenticate with username and password using git.
remote: ! Run `heroku login` to update your credentials, then retry the git command.
remote: ! See documentation for details: https://devcenter.heroku.com/articles/git#http-git-authentication
fatal: Authentication failed for 'https://git.heroku.com/afternoon-fjord-61446.git/'
I'm really don't know what I should do now.
I finally solved it.
I changed my .gitconfig file from default
[credential]
helper = managerd
to
[credential]
helper = manager
and I used username "blank" instead "" (empty string) and its working.

Git:Heroku Repository or object not found:

Here is the error message from Heroku master push command
Git LFS: (0 of 5 files) 0 B / 167.50 MB
batch response: Repository or object not found: https://git.heroku.com/xxxx-brushlands-xx267.git/info/lfs/objects/batch
Check that it exists and that you have proper access to it
error: failed to push some refs to 'https://git.heroku.com/xxxx-brushlands-xx267.git'
Added a long text file to Git LFS (git for large files) and after that Heroku stopped working.
What might be the issue ?
A workaround:
git push heroku master --no-verify
This disables git-lfs pre-push hook. Metadata files are commited but binaries are not uploaded.
Then, as per upendra's answer, a buildpack can be used to download the files.
After alot of googling I found that the problem is with Heroku. If you are using Heroku, then Heroku doesn't support LFS and you have to look for alternatives.
I uploaded my long text file to dropbox and accessing it from there. Heroku should definitely look in to this issue.
I found a temporary solution to the problem of using Git LFS with Heroku. I am just putting it here just in case if people are still looking for it - https://github.com/git-lfs/git-lfs/issues/805
If that doesn't work, then try this out. This method worked for me - https://github.com/raxod502/heroku-buildpack-git-lfs

How can you reference a submodule in openshift

I've got an account with OpenShift which provides a git repository for each project you to work in. I've got one main project and two smaller projects resulting in a total of 3 git repositories.
I have just started to use the two smaller projects in the main project and seen that git can use the submodule command. I've added them both to the custom directory like so:
git submodule add ssh://...#app.rhcloud.com/~/git/app.git/
git submodule add ssh://...#api.rhcloud.com/~/git/api.git/
which has produced a directory structure like so:
node_modules
custom
app ------ full of tasty files
api ------ full of tasty files
index.js
.gitmodules
Within the .gitmodules file I have
[submodule "custom/api"]
path = custom/api
url = ssh://...#api.rhcloud.com/~/git/api.git/
[submodule "custom/app"]
path = custom/app
url = ssh://...#app.rhcloud.com/~/git/app.git/
Which is exactly what I want. It all works locally.
git add --all
git commit -m "new submodules"
git push
The issue is when I run the git push, it comes back with this error:
remote: Host key verification failed.
remote: fatal: Could not read from remote repository.
remote:
remote: Please make sure you have the correct access rights
remote: and the repository exists.
It looks like I need to add the ssh key of the main project to the two smaller projects so that I can ssh. Does anyone know how I can do this or have a better way of including submodules in OpenShift?
Thanks for the help in advance.
It looks like I need to add the ssh key of the main project to the two smaller projects so that I can ssh
At the parent (main) repo level, this shouldn't be the case: all the push does is to push the .gitmodules, and 2 gitlinks (special entries in the index) representing those 2 submodules.
It is more likely that the push doesn't find the proper .ssh/known_hosts, or the public/private ssh keys in order to push back to the app.rhcloud.com upstream repo: See "SSH connection problem with “Host key verification failed…” error" and "The authenticity of host can't be established".

Deploying to heroku from git sub directory

I'm trying to deploy to heroku from a particular directory in my project:
I've tried this command:
git subtree push --prefix output heroku master
and I get the response:
error: failed to push some refs to 'git#heroku.com:intquest.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
Is there a way to --force this command? Or what exactly am I doing wrong?
If you are sure to replace the remote heroku master history with a new one, you can try something similar to this answer:
git push heroku `git subtree split --prefix output master`:master --force

Resources