{"library":"prefect-github","title":"Prefect GitHub","description":"Prefect-github provides Prefect integrations for interacting with GitHub. It includes a `GitHubCredentials` block for secure authentication using Personal Access Tokens (PATs) and various utilities to interact with GitHub repositories, such as cloning, querying repository details, and performing mutations (e.g., adding stars, creating issues). The tasks within this collection were initially generated using the GitHub GraphQL schema. While the standalone `prefect-github` package is currently at version 0.4.2, active development for this integration has been merged into the main PrefectHQ/prefect repository, which follows its own release cadence.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install prefect-github"],"cli":null},"imports":["from prefect_github import GitHubCredentials","from prefect_github.repository import query_repository","from prefect_github.mutations import add_star_starrable","from prefect.runner.storage import GitRepository"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom prefect import flow\nfrom prefect_github import GitHubCredentials\nfrom prefect_github.repository import query_repository\nfrom prefect_github.mutations import add_star_starrable\n\n@flow(log_prints=True)\ndef github_interaction_flow():\n    # It's recommended to store tokens securely, e.g., in Prefect Blocks\n    # and load them by name. For a quickstart, we use an env var.\n    github_token = os.environ.get('GITHUB_PAT', 'YOUR_GITHUB_TOKEN')\n    if github_token == 'YOUR_GITHUB_TOKEN' or not github_token:\n        print(\"Please set the GITHUB_PAT environment variable or replace 'YOUR_GITHUB_TOKEN' with a valid GitHub Personal Access Token.\")\n        return\n\n    # Create a GitHubCredentials block (or load an existing one)\n    github_credentials = GitHubCredentials(token=github_token)\n    # Optionally save the block for re-use in the Prefect UI or other flows:\n    # github_credentials.save(name=\"my-github-pat\", overwrite=True)\n\n    print(f\"Querying repository details for PrefectHQ/prefect...\")\n    repository_info = query_repository(\n        owner=\"PrefectHQ\",\n        name=\"prefect\",\n        github_credentials=github_credentials,\n        return_fields=\"id name url\", # Request specific fields\n    )\n    print(f\"Repository Name: {repository_info.get('name')}\")\n    print(f\"Repository URL: {repository_info.get('url')}\")\n    repository_id = repository_info.get(\"id\")\n\n    if repository_id:\n        print(f\"Attempting to add a star to {repository_info.get('name')} (ID: {repository_id})...\")\n        # Note: Starring requires a PAT with 'public_repo' or 'repo' scope\n        # This action might fail if the token doesn't have sufficient permissions\n        # or if the repository is already starred by the user associated with the token.\n        try:\n            starrable_status = add_star_starrable(\n                starrable_id=repository_id,\n                github_credentials=github_credentials,\n            )\n            print(f\"Star operation successful: {starrable_status.get('starrable', {}).get('viewerHasStarred')}\")\n        except Exception as e:\n            print(f\"Failed to add star: {e}\")\n    else:\n        print(\"Could not retrieve repository ID.\")\n\nif __name__ == \"__main__\":\n    github_interaction_flow()","lang":"python","description":"This quickstart demonstrates how to authenticate with GitHub using `GitHubCredentials` and perform a GraphQL query to get repository details, followed by attempting to add a star to a repository. Ensure you have a GitHub Personal Access Token (PAT) with appropriate scopes (e.g., `public_repo` or `repo`) set as an environment variable named `GITHUB_PAT`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"0.3.2","pypi_latest":"0.4.2","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":20.8,"avg_import_s":6.52,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":6.62,"mem_mb":59.1,"disk_size":"256.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":22.3,"import_time_s":5.43,"mem_mb":59.1,"disk_size":"257M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":8.73,"mem_mb":64.7,"disk_size":"279.3M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":21.6,"import_time_s":7.97,"mem_mb":64.7,"disk_size":"280M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":6.72,"mem_mb":62.3,"disk_size":"268.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":17.8,"import_time_s":7.16,"mem_mb":62.4,"disk_size":"270M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":6.48,"mem_mb":63.8,"disk_size":"265.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":17.7,"import_time_s":6.82,"mem_mb":63.8,"disk_size":"267M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":4.88,"mem_mb":59.7,"disk_size":"188.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"prefect-github","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":24.4,"import_time_s":4.35,"mem_mb":59.7,"disk_size":"189M"}]}}