github#

Description#

This plugin monitors for notifications and events either on Github user, organization or repository level. You’ll need a Github personal access token to use the service. To get one:

  • Access your Github profile settings

  • Select Developer Settings

  • Select Personal access tokens

  • Click Generate new token

This plugin requires the following permissions:

  • repo

  • notifications

  • read:org if you want to access repositories on organization level.

If neither repos nor org is specified then the plugin will monitor all new events on user level.

Configuration#

github:
  # [Required]
  # Github username.
  user:   # type=str

  # [Required]
  # Github personal access token.
  user_token:   # type=str

  # [Optional]
  # List of repos to be monitored - if a list is provided then only these repositories will be
  # monitored for events. Repositories should be passed in the format ``username/repository``.
  # repos:   # type=Optional[List[str]]

  # [Optional]
  # Organization to be monitored - if provided then only this organization will be monitored for events.
  # org:   # type=Optional[str]

  # [Optional]
  # How often the plugin should check for new events, in seconds (default: 60).
  # poll_seconds: 60  # type=int

  # [Optional]
  # Maximum number of events per resource that will be triggered if there is a large
  # number of events/notification since the last check (default: 10). Specify 0 or null for no limit.
  # max_events_per_scan: 10  # type=Optional[int]

  # [Optional]
  # How often the `RunnablePlugin.loop <https://docs.platypush.tech/platypush/plugins/.html#platypush.plugins.RunnablePlugin.loop>`_ function should be
  # executed (default: 15 seconds). *NOTE*: For back-compatibility
  # reasons, the `poll_seconds` argument is also supported, but it's
  # deprecated.
  # poll_interval: 15  # type=Optional[float]

  # [Optional]
  # How long we should wait for any running
  # threads/processes to stop before exiting (default: 5 seconds).
  # stop_timeout: 5  # type=Optional[float]

  # [Optional]
  # If set to True then the plugin will not monitor
  # for new events. This is useful if you want to run a plugin in
  # stateless mode and only leverage its actions, without triggering any
  # events. Defaults to False.
  # disable_monitor: False  # type=bool

Triggered events#

Module reference#

class platypush.plugins.github.GithubPlugin(user: str, user_token: str, repos: List[str] | None = None, org: str | None = None, poll_seconds: int = 60, max_events_per_scan: int | None = 10, **kwargs)[source]#

Bases: RunnablePlugin

This plugin monitors for notifications and events either on Github user, organization or repository level. You’ll need a Github personal access token to use the service. To get one:

  • Access your Github profile settings

  • Select Developer Settings

  • Select Personal access tokens

  • Click Generate new token

This plugin requires the following permissions:

  • repo

  • notifications

  • read:org if you want to access repositories on organization level.

If neither repos nor org is specified then the plugin will monitor all new events on user level.

__init__(user: str, user_token: str, repos: List[str] | None = None, org: str | None = None, poll_seconds: int = 60, max_events_per_scan: int | None = 10, **kwargs)[source]#
Parameters:
  • user – Github username.

  • user_token – Github personal access token.

  • repos – List of repos to be monitored - if a list is provided then only these repositories will be monitored for events. Repositories should be passed in the format username/repository.

  • org – Organization to be monitored - if provided then only this organization will be monitored for events.

  • poll_seconds – How often the plugin should check for new events, in seconds (default: 60).

  • max_events_per_scan – Maximum number of events per resource that will be triggered if there is a large number of events/notification since the last check (default: 10). Specify 0 or null for no limit.

main()[source]#

Implementation of the main loop of the plugin.

start()#

Start the plugin.

stop()#

Stop the plugin.

wait_stop(timeout=None)#

Wait until a stop event is received.

class platypush.plugins.github.GithubResource(**kwargs)[source]#

Bases: Base

Models the GithubLastEvent table, containing the timestamp where a certain URL was last checked.

__init__(**kwargs)#

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.