or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

hooks.mdindex.mdoperators.mdsensors.md
tile.json

tessl/pypi-apache-airflow-providers-github

Apache Airflow provider package for seamless GitHub integration through hooks, operators, and sensors

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/apache-airflow-providers-github@2.9.x

To install, run

npx @tessl/cli install tessl/pypi-apache-airflow-providers-github@2.9.0

index.mddocs/

Apache Airflow Providers GitHub

Apache Airflow provider package for seamless GitHub integration through hooks, operators, and sensors. Enables GitHub repository management, issue tracking, pull request automation, and workflow orchestration within Apache Airflow DAGs using the PyGithub SDK.

Package Information

  • Package Name: apache-airflow-providers-github
  • Language: Python
  • Installation: pip install apache-airflow-providers-github
  • Dependencies: apache-airflow>=2.10.0, PyGithub>=2.1.1

Core Imports

from airflow.providers.github.hooks.github import GithubHook
from airflow.providers.github.operators.github import GithubOperator
from airflow.providers.github.sensors.github import GithubSensor, GithubTagSensor, BaseGithubRepositorySensor
from airflow.providers.github.get_provider_info import get_provider_info
from airflow.providers.github import __version__

Basic Usage

from datetime import datetime
from airflow import DAG
from airflow.providers.github.hooks.github import GithubHook
from airflow.providers.github.operators.github import GithubOperator
from airflow.providers.github.sensors.github import GithubTagSensor

# Create a DAG
dag = DAG(
    'github_example',
    start_date=datetime(2024, 1, 1),
    schedule_interval='@daily',
    catchup=False
)

# Use the hook to connect to GitHub
hook = GithubHook(github_conn_id='github_default')
client = hook.get_conn()
user = client.get_user()

# Use an operator to list repositories
list_repos = GithubOperator(
    task_id='list_repositories',
    github_method='get_user',
    result_processor=lambda user: [repo.name for repo in user.get_repos()],
    dag=dag
)

# Use a sensor to monitor for a tag
wait_for_tag = GithubTagSensor(
    task_id='wait_for_v1_release',
    repository_name='apache/airflow',
    tag_name='v1.0',
    timeout=300,
    dag=dag
)

Architecture

The GitHub provider follows Apache Airflow's standard provider architecture:

  • Hooks: Handle authentication and connection management to GitHub API
  • Operators: Execute GitHub operations as Airflow tasks
  • Sensors: Monitor GitHub resources and trigger downstream tasks
  • Connection Types: Define GitHub connection configuration in Airflow UI

All components use PyGithub as the underlying GitHub SDK and follow Airflow's templating, logging, and error handling patterns.

Capabilities

GitHub Connection Management

Establishes and manages authenticated connections to GitHub API using tokens, with support for GitHub Enterprise through custom base URLs.

class GithubHook(BaseHook):
    def __init__(self, github_conn_id: str = "github_default", *args, **kwargs) -> None: ...
    def get_conn(self) -> GithubClient: ...
    def test_connection(self) -> tuple[bool, str]: ...

GitHub Hooks

GitHub Operations

Execute arbitrary GitHub API operations through PyGithub methods, with support for result processing and templated parameters.

class GithubOperator(BaseOperator):
    def __init__(
        self,
        *,
        github_method: str,
        github_conn_id: str = "github_default",
        github_method_args: dict | None = None,
        result_processor: Callable | None = None,
        **kwargs,
    ) -> None: ...
    def execute(self, context: Context) -> Any: ...

GitHub Operators

GitHub Monitoring

Monitor GitHub resources for changes and trigger downstream tasks based on repository events, tag creation, or custom conditions.

class GithubSensor(BaseSensorOperator):
    def __init__(
        self,
        *,
        method_name: str,
        github_conn_id: str = "github_default",
        method_params: dict | None = None,
        result_processor: Callable | None = None,
        **kwargs,
    ) -> None: ...
    def poke(self, context: Context) -> bool: ...

class GithubTagSensor(BaseGithubRepositorySensor):
    def __init__(
        self,
        *,
        github_conn_id: str = "github_default",
        tag_name: str | None = None,
        repository_name: str | None = None,
        **kwargs,
    ) -> None: ...
    def poke(self, context: Context) -> bool: ...

GitHub Sensors

Provider Metadata

Access provider information and registration details through the provider info function.

def get_provider_info() -> dict:
    """
    Return provider metadata dictionary.
    
    Returns comprehensive provider information including hooks, operators,
    sensors, and connection types for Airflow provider registration.
    
    Returns:
    dict: Provider metadata with integration details
    """

Connection Configuration

Configure GitHub connections in Airflow:

  • Connection Type: github
  • Connection ID: github_default (default)
  • Password: GitHub Personal Access Token (required)
  • Host: GitHub Enterprise base URL (optional, format: https://{hostname}/api/v3)

Types

from typing import Any, TYPE_CHECKING
from collections.abc import Callable
from github import Github as GithubClient, GithubException
from airflow.exceptions import AirflowException
from airflow.providers.github.version_compat import (
    Context, BaseHook, BaseOperator, BaseSensorOperator,
    AIRFLOW_V_3_0_PLUS, AIRFLOW_V_3_1_PLUS
)

# Type aliases used throughout the package
Context = Context  # Airflow execution context
GithubClient = GithubClient  # PyGithub client instance

# Exception types
GithubException = GithubException  # PyGithub API exceptions
AirflowException = AirflowException  # Airflow framework exceptions

# Version-compatible base classes
BaseHook = BaseHook  # Base hook class (version-dependent import)
BaseOperator = BaseOperator  # Base operator class (version-dependent import)  
BaseSensorOperator = BaseSensorOperator  # Base sensor class (version-dependent import)

# Version detection constants
AIRFLOW_V_3_0_PLUS = AIRFLOW_V_3_0_PLUS  # Boolean for Airflow 3.0+ compatibility
AIRFLOW_V_3_1_PLUS = AIRFLOW_V_3_1_PLUS  # Boolean for Airflow 3.1+ compatibility

# Package version
__version__ = "2.9.2"  # Package version string