Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy to Heroku directly from my Gitlab repository

In my team, we use Gitlab as a remote repository, so we are looking for a solution to auto deploy our apps to Heroku. We found Codeship for auto deploying apps to Heroku from Github.

Any tips? Tricks?

like image 481
Toanalien Avatar asked May 05 '16 10:05

Toanalien


People also ask

How do I deploy Heroku with an existing Git repository?

To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.

Can you push to Heroku without GitHub?

You can use https://github.com/ddollar/heroku-push and push directories without git.

How do I link a GitHub repo to Heroku?

Enabling GitHub Integration You can configure GitHub integration in the Deploy tab of apps in the Heroku Dashboard. To configure GitHub integration, you have to authenticate with GitHub. You only have to do this once per Heroku account. GitHub repo admin access is required for you to configure automatic GitHub deploys.


1 Answers

If you are not prepared to use Ruby/dpl you can deploy to Heroku as follows:

Look up your Heroku API key (Account settings -> API Key on the Heroku web console) and make it available as a Gitlab secret variable e.g. HEROKU_API_KEY (Please note the values is not the same as what heroku auth:token returns...)

Then add two script lines in your .gitlab-ci.yml config file at the relevant job:

git remote add heroku https://heroku:[email protected]/<name of your heroku app>.git  git push -f heroku HEAD:master 

You can see detailed explanation at http://blog.thecodewhisperer.com/permalink/deploying-jekyll-to-heroku-using-gitlab-ci

like image 61
Zsolt Avatar answered Oct 07 '22 15:10

Zsolt