Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github & Heroku Webhooks : Add label when pushed to origin, close when pushed to prod

Tags:

git

github

heroku

I love webhooks. Github has them, heroku also. We extensively use the commit messages Fixes #345 git commit message that will close issue 345 when pushed to origin

What I'd like to achieve is:

  • When I push to origin, a label is added to the issue, something like Fixed
  • When I push to my heroku dev app, a label is added to the issue, something like In Dev
  • When I push to my heroku prod app, the issue is actually closed.

Is there a way I can achieve this?

Cheers

like image 786
Augustin Riedinger Avatar asked Feb 20 '14 16:02

Augustin Riedinger


People also ask

What is a GitHub used for?

GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. This tutorial teaches you GitHub essentials like repositories, branches, commits, and pull requests.

Is GitHub free?

GitHub today announced that all of its core features are now available for free to all users, including those that are currently on free accounts.

What is difference Git and GitHub?

what's the difference? Simply put, Git is a version control system that lets you manage and keep track of your source code history. GitHub is a cloud-based hosting service that lets you manage Git repositories. If you have open-source projects that use Git, then GitHub is designed to help you better manage them.

Is GitHub owned by Microsoft?

Microsoft acquired its larger rival GitHub in 2018 for $7.5 billion, which at the time was a high-priced deal in subscription software. GitLab CEO Sid Sijbrandij says his company has more advantages now that GitHub is owned by the world's largest software developer.


2 Answers

Unfortunately, this can't be done by pluging heroku straight to github, as some little data processing is necessary.

I also checked on If this then that if it could be possible, but unfortunately, there is no room for running a little script there, as far as I checked...

I ended up writing my own heroku app that does the job.

https://github.com/copass/copass-hook

  1. When pushed to github, it is actually closed (normal behaviour).
  2. When pushed to dev, a milestone is applied 'In Dev'
  3. When pushed to prod, a milestone is applied 'In Prod'

I considered it more interesting to use milestones as we don't currently use them. But it would be the same logic.

Don't hesitate to fork the app if you like it!

like image 148
Augustin Riedinger Avatar answered Oct 21 '22 00:10

Augustin Riedinger


You can add your own Web Hooks to GitHub using their Web Hooks API.

That should take care of when to run a web hook, but you will need to write you own code for adding labels to your issues which you be achievable using their Issues API.

For Heroku, you'll have to setup a HTTP POST Hook using their Deploy Hooks addon.

like image 42
jordelver Avatar answered Oct 21 '22 00:10

jordelver