class Github::Repos::Hooks
service hooks for a repository.
The Repository Hooks API manages the post-receive web and
def create(*args)
}
}
"url" => "http://something.com/webhook"
"config" => {
"active" => true,
"name" => "web",
github.repos.hooks.create 'user-name', 'repo-name',
github = Github.new
= Examples
* :active - Optional boolean - Determines whether the hook is actually triggered on pushes.
* :events - Optional array - Determines what events the hook is triggered for. Default: ["push"]
* :config - Required hash - A Hash containing key/value pairs to provide settings for this hook.
* :name - Required string - the name of the service that is being called.
= Inputs
Create a hook
def create(*args) arguments(args, :required => [:user, :repo]) do sift VALID_HOOK_PARAM_NAMES, :recursive => false assert_required REQUIRED_PARAMS end post_request("/repos/#{user}/#{repo}/hooks", arguments.params) end
def delete(*args)
github.repos.hooks.delete 'user-name', 'repo-name', 'hook-id'
github = Github.new
= Examples
Delete a hook
def delete(*args) arguments(args, :required => [:user, :repo, :id]) params = arguments.params delete_request("/repos/#{user}/#{repo}/hooks/#{id}", params) end
def edit(*args)
}
"token" => "abc123"
"room" => "Commits",
"subdomain" => "github",
"config" => {
"active" => true,
"name" => "campfire",
github.repos.hooks.edit 'user-name', 'repo-name', 'hook-id',
github = Github.new
= Examples
* :active - Optional boolean - Determines whether the hook is actually triggered on pushes.
* :remove_events - Optional array - Determines a list of events to be removed from the list of events that the Hook triggers for.
* :add_events - Optional array - Determines a list of events to be added to the list of events that the Hook triggers for.
* :events - Optional array - Determines what events the hook is triggered for. This replaces the entire array of events. Default: ["push"].
* :config - Required hash - A Hash containing key/value pairs to provide settings for this hook.
* :name - Required string - the name of the service that is being called.
= Inputs
Edit a hook
def edit(*args) arguments(args, :required => [:user, :repo, :id]) do sift VALID_HOOK_PARAM_NAMES, :recursive => false assert_required REQUIRED_PARAMS end patch_request("/repos/#{user}/#{repo}/hooks/#{id}", arguments.params) end
def get(*args)
github.repos.hooks.get 'user-name', 'repo-name', 'hook-id'
github = Github.new
= Examples
Get a single hook
def get(*args) arguments(args, :required => [:user, :repo, :id]) get_request("/repos/#{user}/#{repo}/hooks/#{id}", arguments.params) end
def list(*args)
github.repos.hooks.list 'user-name', 'repo-name' { |hook| ... }
github.repos.hooks.list 'user-name', 'repo-name'
github = Github.new
= Examples
List repository hooks
def list(*args) arguments(args, :required => [:user, :repo]) response = get_request("/repos/#{user}/#{repo}/hooks", arguments.params) return response unless block_given? response.each { |el| yield el } end
def test(*args)
github.repos.hooks.test 'user-name', 'repo-name', 'hook-id'
github = Github.new
= Examples
This will trigger the hook with the latest push to the current repository.
Test a hook
def test(*args) arguments(args, :required => [:user, :repo, :id]) params = arguments.params post_request("/repos/#{user}/#{repo}/hooks/#{id}/test", params) end