-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduled_workflows.py
49 lines (40 loc) · 1.44 KB
/
scheduled_workflows.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# @@@SNIPSTART data-pipeline-schedule-workflow-python
import asyncio
import os
from datetime import timedelta
from typing import Optional
from temporalio.client import (Client, Schedule, ScheduleActionStartWorkflow,
ScheduleIntervalSpec, ScheduleSpec, TLSConfig)
from github_activity import TASK_QUEUE_NAME
from github_workflows import GitHubRepo, GitHubWorkflow
async def main():
with open(os.getenv("TEMPORAL_MTLS_TLS_CERT"), "rb") as f:
client_cert = f.read()
with open(os.getenv("TEMPORAL_MTLS_TLS_KEY"), "rb") as f:
client_key = f.read()
server_root_ca_cert: Optional[bytes] = None
client = await Client.connect(
os.getenv("TEMPORAL_HOST_URL"),
namespace=os.getenv("TEMPORAL_NAMESPACE"),
tls=TLSConfig(
server_root_ca_cert=server_root_ca_cert,
client_cert=client_cert,
client_private_key=client_key,
),
)
await client.create_schedule(
"reviewers-commenters-schedule",
Schedule(
action=ScheduleActionStartWorkflow(
GitHubWorkflow.run,
GitHubRepo(name="temporalio/documentation"),
id="github-workflow",
task_queue=TASK_QUEUE_NAME,
),
spec=ScheduleSpec(
intervals=[ScheduleIntervalSpec(every=timedelta(days=14))]
),
),
)
if __name__ == "__main__":
asyncio.run(main())