Github integration on AppHarbor not working - appharbor

I can't seem to get Github integration working with my application on AppHarbor. I don't see any errors in the build details, it's just a blank txt in the details... and it never switches to active with the status staying as the red no circle.
I followed the instructions on configuring my github repository with slug and token in the service hooks. The application deploys fine when I push directly to app harbor git.
Is there a trick or a gotcha that I might be forgetting?

If it's a private repository you have to add the apphb user on Github as a collaborator.

For future references, another thing to note is, that it only push the code when it gets commited. Therefor, if you commit, then set up github, you will need to commit again in order to get it pushed.

Related

Deploying from github through Heroku API

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?
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.
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.
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.
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.
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:
This commit will auto-deploy because all of the checks show a status of
success:
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.
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.
Disconnecting account
You can disconnect your Heroku and GitHub accounts in the Applications
pane on your Dashboard account
page.

How to prevent git push heroku master?

My workflow encompasses the following steps:
Git push (to BitBucket or GitHub depending on the project).
BitBucket/GitHub is integrated with CodeShip, tests are run.
If tests are ok, CodeShip automatically deploys to Heroku.
Everything works fine when, by pushing to the remote repo, the deployment tasks are triggered which ends up with the new version going live when everything is ok.
My question is:
Sometimes, I simply do a git push heroku master which defeats the whole purpose of this workflow.
How can I prevent it from happening? Is there a way to make Heroku only accept the deploy when the source is CodeShip?
After looking around for quite some time, I noticed that there are a some ways to accomplish this, all of them related to simply not giving access to the Heroku Account for the developer:
If you're a single developer ("one-man / one-woman show"):
Do not add the Heroku Remote to your Git Repository. If it is already added, remove it. That way you're not going to push to it by mistake.
If you're managing a team:
Do not give the team a user/pass to access Heroku Toolbelt. That way, the only remote repo they will have access to should be GitHub/BitBucket/Whatever.
You could just create another branch called dev and push to that branch your changes and when you are ready to deploy to heroku merge changes into master branch.
I just came accross your issue and this is what i did as quickest resolution

How do you get a BitBucket pull request to trigger a Bamboo build?

I'm working on CI/CD environment for my workplace. One of the issues we're struggling with is the pull request workflow we currently use, and which we want to continue to use.
We can get BitBucket to tell Bamboo to make a build when you commit to a feature branch and push it to BitBucket, but for the life of me I can't find anything in there related to actual pull requests. In our instance, it would be great if a plan branch would be created when a pull request for a feature branch is generated in BitBucket. Subsequent commits would then trigger additional builds on the PR plan branch. Is this even possible on Bamboo with BitBucket?
Updating this to say that proper pull request support was finally added to Bamboo in version 6.0:
release notes
You can now configure the plan branching model to automatically create branches when new PRs are added to Bitbucket.
It looks like somebody answered your question on another forum: https://answers.atlassian.com/questions/17435563/how-do-you-get-a-bitbucket-pull-request-to-trigger-a-bamboo-build which references this feature request for Bamboo: https://jira.atlassian.com/browse/BAM-14844
I'm posting this here for other people like myself who stumble across this question.
The bamboo feature called plan branches has been implemented in recent releases. See the link posted by Mynock, or directly here.

How to push from Gitlab to Github with webhooks

My Google-fu is failing me for what seems obvious if I can only find the right manual.
I have a Gitlab server which was installed by our hosting provider
The Gitlab server has many projects.
For some of these projects, I want that Gitlab automatically pushes to a remote repository (in this case Github) every time there is a push from a local client to Gitlab.
Like this: client --> gitlab --> github
Any tags and branches should also be pushed.
AFAICT I have 3 options:
Configure the local client with two remotes, and push simultaneous to Gitlab and Github. I want to avoid this because developers.
Add a git post-receive hook in the repository on the Gitlab server. This would be most flexible (I have sufficient Linux experience to write shell scripts as git hooks) and I have found documentation on how to do this, but I want to avoid this too because then the hosting provider will need to give me shell access.
I use webhooks in Gitlab. I am unfamiliar with what the very basics of webhooks are, and I am unable to locate understandable documentation or even a simple step-by-step example. This is the documentation from Gitlab that I found and I do not understand it: http://demo.gitlab.com/help/web_hooks/web_hooks
I would appreciate good pointers, and I will summarize and document a solution when I find it.
EDIT
I'm using this Ruby code for a web hook:
class PewPewPew < Sinatra::Base
post '/pew' do
push = JSON.parse(request.body.read)
puts "I got some JSON: #{push.inspect}"
end
end
Next: find out how to tell the gitlab server that it has to push a repository. I am going back to the GitLab API.
EDIT
I think I have an idea. On the server where I run the webhook, I pull from GitLab and then I push to Github. I can even do some "magic" (running tests, building jars, deploying to Artifactory,...) before I push to GitHub. In fact it would be great if Jenkins were able to push to a remote repository after a succesful build, then I wouldn't need to write my own webhook, because I'm pretty sure Jenkins already provides a webhook for Gitlab, either native or via a plugin. But I don't know. Yet.
EDIT
I solved it in Jenkins.
You can set more than one git remote in an Jenkins job. I used Git Publisher as a Post-Build Action and it worked like a charm, exactly what I wanted.
would work of course.
is possible but dangerous because GitLab shell automatically symlinks hooks into repositories for you, and those are necessary for permission checks: https://github.com/gitlabhq/gitlab-shell/tree/823aba63e444afa2f45477819770fec3cb5f0159/hooks so I'd rather stay away from it.
Web hooks are not suitable directly: they make an HTTP request with fixed format on certain events, in your case push, not Git protocol requests.
Of course, you could write a server that consumes the hook, clones and pushes, but a service (single push and no deployment) or GitLab CI (already implements hook management) would be strictly better solutions.
services are a the best option if someone implements it: live in the source tree, would do a single push, and require no extra deployment overhead.
GitLab CI or othe CIs like Jenkins are the best option currently available. They are essentially already implemented server for the webhooks, which automatically clone for you: all you have to do then is to push from them.
The keywords you want to Google for are "gitlab mirror github". That has led me to: Gitlab repository mirroring for instance. There seems to be no perfect, easy solution today.
Also this has already been proposed at the feature request forum at: http://feedback.gitlab.com/forums/176466-general/suggestions/4614663-automatic-push-to-remote-mirror-repo-after-push-to Always check there ;) Go and upvote the request.
The key difficulty now is how to store the push credentials.
I solved it in Jenkins. You can set more than one git remote in an Jenkins job. I used Git Publisher as a Post-Build Action and it worked like a charm, exactly what I wanted.
I added "-publisher" jobs that run after "" is built successfully. I could have done it in one job, but I decided to split it up. The build jobs are triggered by a web hook in GitLab; the publisher jobs are using a #daily schedule from the BuildResultTrigger plugin.

Deploying a Github App on Heroku

I have been trying to deploy from a GitHub repository to Heroku. For pushing my changes to GitHub I am using Mac UI Client for GitHub.
Now in the heroku app setup, I changed at https://dashboard.heroku.com/apps/myapp/settings . Here I made changes in option GitHub Rep (Link your app to a GitHub repository to see commit diffs in the activity log.). I added as my github-user/repository-name
Now when i use myappname.heroky.com I am redirected to a default page which says :
Heroku | Welcome to your new app! Refer to the documentation if you
need help deploying.
In the documentation it is all commands which is going over me since i use Github UI tool.
Any idea if this can be deployed w/o using the commands?
I am asking this particular thing, since last time I used AppHarbor and it simply pulled my github rep w/o any hiccups.
Adding your GitHub repo to the Heroku app settings will not set up automatic deployments. It just allows Heroku to provide commit information in the app logs.
To achieve what you are looking for, you need to set up continuous deployment (or "CD"). The easiest way to do this is with a continuous integration (or "CI") solution.
One common CI server is Jenkins, though that will require you to set it up manually. Nowadays, there are several automated CI/CD services you can take advantage of, including Travis, CircleCI, Codeship, Snap. All of them have options to automatically deploy to Heroku after building your app (which can be trigger by a push to GitHub).

Resources