How to auto-update composer packages with webhooks
In the previous tutorial, created, published and used our own package, we saw that by default, packages don’t auto-update. This implies that whenever we update our repository where these packages are hosted, we need to manually login to Packagist and update this package manually by clicking the update button in our dashboard. This experience could be very tiresome, and we wouldn’t want to do that. Thus, the need to auto-update our packages on Packagist each time our packet repository changes.
In this tutorial, we will make that package we created in the last tutorial to auto-update, wherever there is a change in our git repository.
To achieve this, we will make use of Webhook feature in GitHub, whose functionality could be summarized as that of an HTTP callback.
The concept of webhook could be easily understood, it is more of a http call back, an HTTP POST that gets fired whenever something happens by sending a simple event notification.
In our case, this HTTP POST will get fired automatically by GitHub anytime there is push to our GitHub repository.
#Activating Webhook on GitHub
To activate this feature on our package, we will follow the steps below:
- We will navigate to GitHub, and open the repository that has our published package
- On this page we will click on “Settings” at the menu bar.
- Then from the nav bar on the left, Select the option Webhook.
When the Webhook tab opens, we will have some couple of fields to fill, which includes: Payload URL, Content Type and Secret.
#Payload: This is a unique URL, that is specific to your package on Packagist.
#Content type: This specifies how we want GitHub to send our updated packages to Packagist.
#Secret: This is a unique key generate by Packagist, to ensure that any data its receiving is fully authorized.
These three options could be gotten from our Packagist dashboard here.
After filling in these fields, the above screenshot shows that GitHub has been successfully been integrated into our package on Packagist and will be automatically update each time our GitHub repository is updated.
Yahh! finally we have successfully made our package to be auto-updating. Don’t forget to like and share and comment on the comment section. Follow us on twitter for more updates.
- Weekly Trends
- 100 Python Projects for Beginners with solution
- Mastering NumPy: 100 Exercises with solutions
- SQL Tutorial
- SQL Inner Join
- Python Exercises, Practice, Solution
- Python Interview Questions and Answers: Comprehensive Guide
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises