-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path__main__.py
53 lines (42 loc) · 1.28 KB
/
__main__.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
50
51
52
53
import argparse
import pydantic
from .conditions import Condition
from .deploy import maybe_deploy_next
from .github import GithubClient
from .settings import Settings
class EnvironmentConfig(pydantic.BaseModel):
name: str
conditions: list[Condition]
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
"--branch",
type=str,
help=(
"Branch to deploy from. If not specified or "
"empty the project's default branch is used"
),
)
parser.add_argument(
"environments",
type=str,
help="JSON containing configuration for each environments",
)
args = parser.parse_args()
settings = Settings()
client = GithubClient(
repo=settings.GITHUB_REPOSITORY,
base_url=settings.GITHUB_API_URL,
token=settings.GITHUB_TOKEN,
)
environments = pydantic.parse_raw_as(list[EnvironmentConfig], args.environments)
for environment in environments:
print(f"Checking {environment.name}")
maybe_deploy_next(
client=client,
environment=environment.name,
conditions=environment.conditions,
branch=args.branch if args.branch else None,
)
if __name__ == "__main__":
main()