spcd/cd/project.py

34 lines
810 B
Python
Raw Normal View History

2024-06-09 16:09:53 +00:00
from pathlib import Path
2024-04-27 14:14:03 +00:00
BRANCH = [
2024-06-08 21:56:21 +00:00
"GITHUB_REF_NAME",
"CI_COMMIT_BRANCH",
2024-04-27 14:14:03 +00:00
]
NAME = [
2024-06-08 21:56:21 +00:00
"GITHUB_REPOSITORY",
"CI_PROJECT_PATH",
2024-04-27 14:14:03 +00:00
]
2024-05-29 22:21:42 +00:00
ROOT = [
2024-06-08 21:56:21 +00:00
"GITHUB_WORKSPACE",
"CI_PROJECT_DIR",
2024-05-29 22:21:42 +00:00
]
2024-04-27 14:14:03 +00:00
2024-04-27 13:32:33 +00:00
class Project:
2024-06-08 21:59:45 +00:00
def __init__(self, projects) -> None:
2024-04-27 15:09:51 +00:00
self.projects = projects
2024-04-27 14:14:03 +00:00
# branch
for variable in BRANCH:
2024-04-27 15:09:51 +00:00
if value := projects.environment.get(variable, None):
2024-04-27 14:14:03 +00:00
self.branch = value
# name
for variable in NAME:
2024-04-27 15:09:51 +00:00
if value := projects.environment.get(variable, None):
2024-06-09 16:09:53 +00:00
self.name = Path(value).name
2024-05-29 22:21:42 +00:00
# root
for variable in ROOT:
if value := projects.environment.get(variable, None):
self.root = value
2024-04-27 15:09:51 +00:00
# url
2024-06-09 16:09:53 +00:00
self.url = Path(projects.url) / self.name