Filter uncanny-automator-pro

automator_github_pro_webhook_events

Filter GitHub webhook events. Filters GitHub webhook events, allowing modification of the event array before processing.

add_filter( 'automator_github_pro_webhook_events', $callback, 10, 1 );

Description

Filters the list of available GitHub webhook events within Uncanny Automator Pro. Developers can add, remove, or modify events, each represented as an associative array with 'text' and 'value' keys. This hook fires when fetching event options for GitHub triggers, allowing customization of event selection.


Usage

add_filter( 'automator_github_pro_webhook_events', 'your_function_name', 10, 1 );

Parameters

$events (array)
@property text - The text to display for the event. @property value - The value to use for the event.

Return Value

array


Examples

/**
 * Add a custom GitHub webhook event for when a new repository is created.
 */
add_filter( 'automator_github_pro_webhook_events', function( $events ) {
    // Add our new event to the existing list of events.
    $events[] = array(
        'text'  => esc_html_x( 'New repository created', 'GitHub', 'uncanny-automator-pro' ),
        'value' => 'repository_created',
    );

    // Return the modified array of events.
    return $events;
}, 10, 1 ); // Priority 10, accepts 1 argument

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

uncanny-automator-pro/src/integrations/github/helpers/github-app-helpers.php:146

public function get_event_options() {
		$events = array(
			array(
				'text'  => esc_html_x( 'Push', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'push',
			),
			array(
				'text'  => esc_html_x( 'Pull request', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'pull_request',
			),
			array(
				'text'  => esc_html_x( 'Issues', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'issues',
			),
			array(
				'text'  => esc_html_x( 'Issue comment', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'issue_comment',
			),
			array(
				'text'  => esc_html_x( 'Pull request review', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'pull_request_review',
			),
			array(
				'text'  => esc_html_x( 'Release', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'release',
			),

			array(
				'text'  => esc_html_x( 'Delete', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'delete',
			),
			array(
				'text'  => esc_html_x( 'Fork', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'fork',
			),
			array(
				'text'  => esc_html_x( 'Star', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'star',
			),
			array(
				'text'  => esc_html_x( 'Commit comment', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'commit_comment',
			),
			array(
				'text'  => esc_html_x( 'Workflow run', 'GitHub', 'uncanny-automator-pro' ),
				'value' => 'workflow_run',
			),
		);

		/**
		 * Filter GitHub webhook events.
		 *
		 * @link https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads
		 *
		 * @param array $events
		 * @property text - The text to display for the event.
		 * @property value - The value to use for the event.
		 *
		 * @return array
		 *
		 * @example:
		 * add_filter( 'automator_github_pro_webhook_events', function( $events ) {
		 *     $events[] = array(
		 *         'text'  => esc_html_x( 'Team member added', 'GitHub', 'uncanny-automator-pro' ),
		 *         'value' => 'team_add',
		 *     );
		 *     return $events;
		 * } );
		 */
		$events = apply_filters( 'automator_github_pro_webhook_events', $events );

		return $events;
	}

Internal Usage

Found in uncanny-automator-pro/src/integrations/github/helpers/github-app-helpers.php:138:

* add_filter( 'automator_github_pro_webhook_events', function( $events ) {
Scroll to Top