Git commit notification
A symfony application to allow receiving commit notification for all commits in a certain time period.
Features:
- Receive one mail for all commits within a certain time period. Once per one, two, three, fours hours or daily or weekly.
- Exclude (or include) certain commit messages, files, or authors.
- Receive commits in a single mail for multiple repositories.
- Light or dark theme notification mail.
- Add links to your task or jira board based on the commit message.
Examples:
- Watch changes for
composer.json
for one or more repositories. - Exclude all commits done by ci- or other automated processes.
- Exclude changes done to
composer.lock
for a repository.
Themes
Requirements
- recent version of
git
- php version > 7.4
Quick start
git clone https://github.com/123inkt/git-commit-notification.git git-commit-notification
cd git-commit-notification
composer install --optimize-autoloader --classmap-authoritative --no-dev --no-progress
composer dump-env prod
Check .env
for mailer settings, update (if necessary)
MAILER_DSN=native://default
MAILER_SENDER='Sherlock Holmes <[email protected]>'
Create config in the root of the project:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="config.xsd">
<repositories>
<repository name="example" url="https://username:[email protected]/example.git"/>
</repositories>
<rule>
<name>Example repository once per hour</name>
<repositories>
<repository name="example"/>
</repositories>
<recipients>
<recipient email="[email protected]" name="Sherlock Holmes"/>
</recipients>
</rule>
</configuration>
See configuration for more configuration options.
Add to crontab:
0 */1 * * * /usr/bin/php /path/to/bin/console mail --frequency=once-per-hour > /dev/null 2>&1
0 */2 * * * /usr/bin/php /path/to/bin/console mail --frequency=once-per-two-hours > /dev/null 2>&1
0 */3 * * * /usr/bin/php /path/to/bin/console mail --frequency=once-per-three-hours > /dev/null 2>&1
0 */4 * * * /usr/bin/php /path/to/bin/console mail --frequency=once-per-four-hours > /dev/null 2>&1
0 0 * * * /usr/bin/php /path/to/bin/console mail --frequency=once-per-day > /dev/null 2>&1
0 0 * * 1 /usr/bin/php /path/to/bin/console mail --frequency=once-per-week > /dev/null 2>&1
See command line options for more information about the console commands.
Under the hood
- Will fetch all commits for a given repository via the
git log
command. - Will bundle commits when author, branch and subject are identical.
- For a set of commits, fetches the bundled changes between the first commit and the last
- Send a notification mail in the desired formatting
Troubleshooting
I'm not getting mails:
- In
.env
verify MAILER_DSN is set correctly. See https://symfony.com/doc/current/mailer.html#using-built-in-transports - Run command with
-vvv
for verbose output. Verify your rules are configured correctly. - send a test mail
php bin/console test:mail [email protected]
- Check the mail log for additional error messages. Depending on your system check:
- /var/log/maillog
- /var/log/mail.log
- /var/adm/maillog
- /var/adm/syslog/mail.log
About us
At 123inkt (Part of Digital Revolution B.V.), every day more than 30 developers are working on improving our internal ERP and our several shops. Do you want to join us? We are looking for developers.