github

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2021 License: BSD-3-Clause Imports: 18 Imported by: 1

README

go-webhookd-github

go-webhookd support for GitHub.

go-webhookd

Before you begin please read the go-webhookd documentation for an overview of concepts and principles.

Usage

import (
	_ "github.com/go-webhookd-github"
)

Receivers

GitHub

The GitHub receiver handles Webhooks sent from GitHub. It validates that the message sent is actually from GitHub (by way of the X-Hub-Signature header) but performs no other processing. It is defined as a URI string in the form of:

github://?secret={SECRET}&ref={REF}
Properties
Name Value Description Required
secret string The secret used to generate the HMAC hex digest of the message payload. yes
ref string An optional Git ref to filter by. If present and a WebHook is sent with a different ref then the daemon will return a 666 error response. no

Transformations

GitHubCommits

The GitHubCommits transformation will extract all the commits (added, modified, removed) from a push event and return a CSV encoded list of rows consisting of: commit hash, repository name, path. For example:

e3a18d4de60a5e50ca78ca1733238735ddfaef4c,sfomuseum-data-flights-2020-05,data/171/316/450/9/1713164509.geojson
e3a18d4de60a5e50ca78ca1733238735ddfaef4c,sfomuseum-data-flights-2020-05,data/171/316/451/9/1713164519.geojson
e3a18d4de60a5e50ca78ca1733238735ddfaef4c,sfomuseum-data-flights-2020-05,data/171/316/483/5/1713164835.geojson

It is defined as a URI string in the form of:

githubcommits://?exclude_additions={EXCLUDE_ADDITIONS}&exclude_modification={EXCLUDE_MODIFICATIONS}&exclude_deletions={EXCLUDE_DELETIONS}
Properties
Name Value Description Required
exclude_additions boolean A flag to indicate that new additions in a commit should be ignored. no
exclude_modifications boolean A flag to indicate that modifications in a commit should be ignored. no
exclude_deletions boolean A flag to indicate that deletions in a commit should be ignored. no
GitHubRepo

The GitHubRepo transformation will extract the reporsitory name for all the commits matching (added, modified, removed) criteria. It is defined as a URI string in the form of:

githubrepo://?exclude_additions={EXCLUDE_ADDITIONS}&exclude_modification={EXCLUDE_MODIFICATIONS}&exclude_deletions={EXCLUDE_DELETIONS}
Properties
Name Value Description Required
exclude_additions boolean A flag to indicate that new additions in a commit should be ignored. no
exclude_modifications boolean A flag to indicate that modifications in a commit should be ignored. no
exclude_deletions boolean A flag to indicate that deletions in a commit should be ignored. no

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSignature

func GenerateSignature(body string, secret string) (string, error)

func NewGitHubCommitsTransformation

func NewGitHubCommitsTransformation(ctx context.Context, uri string) (webhookd.WebhookTransformation, error)

func NewGitHubReceiver

func NewGitHubReceiver(ctx context.Context, uri string) (webhookd.WebhookReceiver, error)

func NewGitHubRepoTransformation

func NewGitHubRepoTransformation(ctx context.Context, uri string) (webhookd.WebhookTransformation, error)

func UnmarshalEvent

func UnmarshalEvent(event_type string, body []byte) (interface{}, error)

Types

type GitHubCommitsTransformation

type GitHubCommitsTransformation struct {
	webhookd.WebhookTransformation
	ExcludeAdditions     bool
	ExcludeModifications bool
	ExcludeDeletions     bool
}

func (*GitHubCommitsTransformation) Transform

func (p *GitHubCommitsTransformation) Transform(ctx context.Context, body []byte) ([]byte, *webhookd.WebhookError)

type GitHubReceiver

type GitHubReceiver struct {
	webhookd.WebhookReceiver
	// contains filtered or unexported fields
}

func (GitHubReceiver) Receive

func (wh GitHubReceiver) Receive(ctx context.Context, req *http.Request) ([]byte, *webhookd.WebhookError)

type GitHubRepoTransformation

type GitHubRepoTransformation struct {
	webhookd.WebhookTransformation
	ExcludeAdditions     bool
	ExcludeModifications bool
	ExcludeDeletions     bool
}

func (*GitHubRepoTransformation) Transform

func (p *GitHubRepoTransformation) Transform(ctx context.Context, body []byte) ([]byte, *webhookd.WebhookError)

Directories

Path Synopsis
cmd
webhookd-github command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL