Skip to content

Commit

Permalink
Adds example of deploying from a GitHub repo
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilRex committed Dec 5, 2024
1 parent 4781565 commit 59f2d5d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deploy/source-docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def deploy():
source="./flows",
entrypoint="hello-world.py:hello",
).deploy(
name="default",
name="source-docker",
# The name of the work pool to use for this deployment
work_pool_name="docker",
image=DockerImage(
Expand Down
47 changes: 47 additions & 0 deletions deploy/source-github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
# Deploy a flow from a git repository
This example shows how to deploy a flow from a git repository.
It assumes you have a work pool named `process`. You can implicitly create the
work pool by starting a worker:
```bash
prefect worker start --pool process --type process
```
"""

from prefect import flow
from prefect.runner.storage import GitRepository
from prefect.blocks.system import Secret
from prefect.client.schemas.schedules import CronSchedule


def deploy():
# flow.from_source will actually clone the repository to load the flow
flow.from_source(
# Here we are using GitHub but it works for GitLab, Bitbucket, etc.
source=GitRepository(
url="https://github.com/PrefectHQ/examples.git",
credentials={
# We are assuming you have a Secret block named `github-access-token`
# that contains your GitHub personal access token
"access_token": Secret.load("github-access-token"),
},
),
entrypoint="flows/hello-world.py:hello",
).deploy(
name="source-github",
schedules=[
# Run the flow every hour on the hour
CronSchedule(cron="0 * * * *"),
],
work_pool_name="process",
# Define a different default parameter for this deployment
parameters={
"name": "Arthur",
},
)


if __name__ == "__main__":
deploy()

0 comments on commit 59f2d5d

Please sign in to comment.