Skip to content

SaiZawMyint/git-notifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-notifier

The git events notifiers, you can implement it to handle all of your Git events happening at any time.

What you need?

We use the Git webhook technology to handle all of the Git events, so we need some things for the implementation.

How to use?

First of all, open the terminal at the location of your project folder, and clone the repository.

git clone https://github.com/SaiZawMyint/git-notifier.git

And install the necessary packages, by running

cd git-notifier
composer install

Start the local development

Now, we are ready to start our local development server.

php -S localhost:8080

To test the notification, open your browser, and on the URL bar, enter the following URL and press enter

http://localhost:8080/test-noti

You will get the test notification message.(NOTE: You must enable system notification on your device. If you have blocked the notifications, the notification will not send to your device!)

We have done our local development, and now let's continue to configure the Git webhook.

Expose the local server

As Git webhook payload URL, allows only HTTPS so we need to expose our local server to HTTPS. To do it we will use the Ngrok. If you have not installed the Ngrok on your device go to the download page here and install it.

Open the terminal and enter the following

ngrok http 8080

You will get the log on the command like this

Session Status                online
Account                       {{your ngrok account email}} (Plan: Free)
Version                       3.3.1                                                                                     
Region                        Asia Pacific (ap)
Latency                       45ms
Web Interface                 http://127.0.0.1:4040
Forwarding                    https://{{your-ngrok-custom-ips}}.ngrok-free.app -> http://localhost:8080
Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

At the Forwarding sentence, copy the URL exposed by Ngrok. Now we get the exposed URL for our local development.

Configure Git Webhook

Let's start to configure our git webhook.

  • Go to your Git profile.

  • Choose the repository you want to implement the Git event.

  • Go to the settings page.

  • image

  • Click on Webhooks at the sidebar.

  • image

  • Add new Webhook.

  • At the payload URL, paste your ngrok URL that is exposed from your local server. (Don't forget to add the '/git' at the ent of the URL)

  • image

  • Scroll down and at the Which events would you like to trigger this webhook?, choose the Send me everything.

  • image

  • Click on Add webhooks button (You can skip other input after you have completed the above options)

Congratulations, we have done all of the implementation.


Test

Make some event to the repository you have configured the webhook, like push, fork, giving stars, issues, pull request, etc... You will Get a notification every time an event happened on your repository.

When to use?

As the project is to handle the Git event, you can use it when you want to notify the event of your Git repository. It's very useful when you have a development team and you want to know who has pushed to the repository or who has PR to the repository or other actions happening between your team development.


Hope this help you in your improvement or development with Git. :D

Thank you.

About

The git events notifiers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages