Deploying from github through Heroku API
Asked Answered
V

2

7

Background: I have a project deployed to heroku. The heroku app is connected with github so I can press the "deploy" button from heroku's web api to manually deploy a branch on github to heroku.

What I'm trying to do is build a slack bot that will let me accomplish that via a slack command. Ideally, there'd be some function on heroku's platform api like .deploy('my_app', 'some_branch_on_github), but I can't seem to find it.

The platform api's build feature is close. That function lets you provide the public url of a tarball that heroku will then deploy. However, my github repo isn't public, so that doesn't work. A private repo shouldn't be a problem, though, since heroku's already connected to my github repo.

TLDR: How can I programmatically tell Heroku to deploy my app from a private github it's connected to?

Vervain answered 18/7, 2016 at 4:1 Comment(0)
V
11

I got a response from Heroku's support team asking pretty much the same question. Their answer was that what I'm trying to do is not possible, but will be at some point (although not in the next few months, anyway).

They suggested that I could just use the undocumented web api used by heroku's own web console (a POST to an endpoint on kolkrabbi.heroku.com). They did warn that, as a private api, that's likely to change without warning.

Vervain answered 20/7, 2016 at 21:27 Comment(3)
Could that be any more vague of a name btw? kolkrabbi.heroku.com i saw it in my github webhook list and google lead me here. thanks for clearing it upDumpling
Yeah, it probably matches some internal naming scheme for their hosts, since it's not meant to be public facing.Vervain
Kolbrakki is an icelandic word and means Octopus, which is I believe Github's mascot :)Kingcraft
I
0

As of April 2020, Heroku has integrated GitHub natively without recourse to any janky undocumented Icelandic endpoints.

When configured, Heroku can automatically build and release (if the build is successful) pushes to the specified GitHub repo.

Enabling GitHub integration

You can configure GitHub integration in the Deploy tab of apps in the Heroku Dashboard.

Enable GitHub
integration

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. This is because Heroku has to register a service hook on the GitHub repo, and this action requires admin access. For GitHub organizations, your GitHub account will also need to be a member of the organization and not an outside collaborator.

 

If your repo is in a GitHub organization that has third-party application restrictions enabled, an organization admin needs to approve Heroku for use with the organization. More details are available on GitHub.

After you link your Heroku app to a GitHub repo, you can selectively deploy from branches or configure auto-deploys.

Manual deploys

With manual deploys, you can create an immediate deployment of any branch from the GitHub repo that’s connected to your app. Use manual deploys if you want to control when changes are deployed to Heroku.

Manual
deploy

You can also use manual deploys to temporarily deploy a branch other than the one that’s configured for automatic deployment. For example, you might have a development app synced to the development GitHub branch, but you temporarily want to test a feature branch. Simply trigger a manual deploy of the feature branch to test it on the Heroku app. Note that release of the feature branch is overwritten on the next successful GitHub push to the development branch.

Automatic deploys

When you enable automatic deploys for a GitHub branch, Heroku builds and deploys all pushes to that branch. If, for example, you have a development app on Heroku, you can configure pushes to your GitHub development branch to be automatically built and deployed to that app.

Automatic
deploys

If you’ve configured your GitHub repo to use automated Continuous Integration (with Travis CI, for example), you can check the “Wait for CI to pass before deploy” checkbox. When enabled, Heroku will only auto-deploy after all the commit statuses of the relevant commit show success.

This commit won’t auto-deploy because one of the checks shows a pending status: Failed commit status - won't
auto-deploy

This commit will auto-deploy because all of the checks show a status of success: Success commit statuses - will
auto-deploy

Review apps

With review apps enabled for a Heroku app, Heroku will create temporary test apps for each pull request that’s opened on the GitHub repo that’s connected to the parent app. Review apps are great if you’re using GitHub Flow to propose, discuss, and merge changes to your code base. Because pull request branches are deployed to new apps on Heroku, it’s very simple for you and your collaborators to test and debug code branches. You can also run automated integration tests on the Heroku app representing a GitHub branch.

See the Review apps article for details.

Heroku CI

Once you’ve connected your GitHub repo to your Pipeline, you can turn on Heroku CI, our visual, low-configuration test runner that integrates easily with Heroku Pipelines (and so complements Review apps, existing Heroku apps, and our GitHub integrations). Any Heroku Pipeline is already Heroku CI ready – just turn it on in the Pipeline’s Settings tab.

Links to diffs

For apps that are linked to GitHub repos, releases in the Dashboard Activity tab will include a “View Diff” link. Following the link will take you to the GitHub comparison view, showing the changes made since the last release.

Diff view
link

Disconnecting from GitHub

Terminate an obsolete GitHub connection, if necessary.

Disconnecting individual apps

Individual apps can be disconnected in the GitHub pane of the Deploy tab for the app.

Screenshot of UI to disconnect
app

Disconnecting account

You can disconnect your Heroku and GitHub accounts in the Applications pane on your Dashboard account page.

Screenshot of UI to disconnect
accounts

Incompliant answered 15/10, 2021 at 6:52 Comment(1)
This doesn't answer the original question.Najera

© 2022 - 2025 — McMap. All rights reserved.