Git Product home page Git Product logo

git-discord-hook's Introduction

Git post-receive hook for Discord

(Based on https://github.com/chriseldredge/git-slack-hook)

This is a bash script that posts a message into your Discord channel when changes are pushed.

Hook this script into post-receive for your git repositories.

How to Install

Note: some git repositories may be "bare". You'll know if your repo is bare or not by checking for a .git folder where your repo lives.

Download git-discord-hook onto the server which hosts your git repo.

For bare repos, copy/rename it as /path/to/your/repo/hooks/post-receive.

For normal/non-bare repos, copy/rename it as /path/to/your/repo/.git/hooks/post-receive.

Finally, chmod +x post-receive to allow the script to be executed.

Configuration

Add an Incoming WebHooks integration in your Discord by going to:

Server Settings -> Webhooks -> Create Webhook

For a normal/non-bare repo, configure the webhook URL

git config hooks.discord.webhook-url 'https://discordapp.com/api/webhooks/{webhook.id}/{webhook.token}'

For a bare repo:

git config -f /path/to/your/repo/config hooks.discord.webhook-url 'https://discordapp.com/api/webhooks/{webhook.id}/{webhook.token}'

Optional

Specify a username to post as. If not specified, the default name incoming-webhook will be used:

git config hooks.discord.username 'git'

Specify an icon to display in Discord instead of the default:

git config hooks.discord.icon-url 'https://example.com/icon.png'

Specify a repository nice name that will be shown in messages:

git config hooks.discord.repo-nice-name 'My Awesome Repository'

Specify whether you want to show only the last commit (or all) when pushing multiple commits:

git config hooks.discord.show-only-last-commit true

Specify whether you want to show the body of the commit message as well as the title:

git config hooks.discord.show-full-commit true

Specify if you want to send only certain branches:

git config hooks.discord.branch-regexp regexp

Linking to Changesets

When the following parameters are set, revision hashes will be turned into links to a web view of your repository.

git config hooks.discord.repos-root '/path/to/repos'
git config hooks.discord.changeset-url-pattern 'http://yourserver/%repo_path%/changeset/%rev_hash%'

For example, if your repository is in /usr/local/repos/myrepo, set repos_root to /usr/local/repos/ and set changeset_url_pattern to http://yourserver/%repo_path%/changeset/%rev_hash% or whatever.

Links can also be created that summarize a list of commits:

git config hooks.discord.compare-url-pattern 'http://yourserver/%repo_path%/compare/%old_rev_hash%..%new_rev_hash%'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.