community.general.github_webhook (8.5.0) — module

Manage GitHub webhooks

Authors: Chris St. Pierre (@stpierre)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Create and delete GitHub webhooks


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a new webhook that triggers on push (password auth)
  community.general.github_webhook:
    repository: ansible/ansible
    url: https://www.example.com/hooks/
    events:
      - push
    user: "{{ github_user }}"
    password: "{{ github_password }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a new webhook in a github enterprise installation with multiple event triggers (token auth)
  community.general.github_webhook:
    repository: myorg/myrepo
    url: https://jenkins.example.com/ghprbhook/
    content_type: json
    secret: "{{ github_shared_secret }}"
    insecure_ssl: true
    events:
      - issue_comment
      - pull_request
    user: "{{ github_user }}"
    token: "{{ github_user_api_token }}"
    github_url: https://github.example.com
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete a webhook (password auth)
  community.general.github_webhook:
    repository: ansible/ansible
    url: https://www.example.com/hooks/
    state: absent
    user: "{{ github_user }}"
    password: "{{ github_password }}"

Inputs

    
url:
    description:
    - URL to which payloads will be delivered
    required: true
    type: str

user:
    description:
    - User to authenticate to GitHub as
    required: true
    type: str

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Whether the hook should be present or absent
    required: false
    type: str

token:
    description:
    - Token to authenticate to GitHub with
    required: false
    type: str

active:
    default: true
    description:
    - Whether or not the hook is active
    required: false
    type: bool

events:
    description:
    - 'A list of GitHub events the hook is triggered for. Events are listed at U(https://developer.github.com/v3/activity/events/types/).
      Required unless O(state=absent)

      '
    elements: str
    required: false
    type: list

secret:
    description:
    - The shared secret between GitHub and the payload URL.
    required: false
    type: str

password:
    description:
    - Password to authenticate to GitHub with
    required: false
    type: str

github_url:
    default: https://api.github.com
    description:
    - Base URL of the GitHub API
    required: false
    type: str

repository:
    aliases:
    - repo
    description:
    - Full name of the repository to configure a hook for
    required: true
    type: str

content_type:
    choices:
    - form
    - json
    default: form
    description:
    - The media type used to serialize the payloads
    required: false
    type: str

insecure_ssl:
    default: false
    description:
    - 'Flag to indicate that GitHub should skip SSL verification when calling the hook.

      '
    required: false
    type: bool

Outputs

hook_id:
  description: The GitHub ID of the hook created/updated
  returned: when state is 'present'
  sample: 6206
  type: int