Yaron Levi
06/20/2024, 8:19 AMMarvin
06/20/2024, 8:19 AMGitHubCredentials with flow.from_source.
Here's an example of how to use it:
python
from prefect import flow
from prefect_github import GitHubCredentials
if __name__ == "__main__":
    flow.from_source(
        source=GitRepository(
            url="<https://github.com/org/private-repo.git>",
            credentials=GitHubCredentials.load("my-github-credentials-block")
        ),
        entrypoint="my_file.py:my_flow",
    ).deploy(
        name="private-github-deploy",
        work_pool_name="my_pool",
        build=False
    )
Alternatively, if you use a prefect.yaml file to create the deployment, you can reference the GitHub Credentials block in the pull step:
yaml
pull:
  - prefect.deployments.steps.git_clone:
      repository: "<https://github.com/org/repo.git>"
      credentials: "{{ prefect.blocks.github-credentials.my-github-credentials-block }}"
For more details, consult the Prefect GitHub Integration Documentation.