spcd/cd/project.py

26 lines
603 B
Python
Raw Normal View History

2024-04-27 14:14:03 +00:00
from os import path
BRANCH = [
'GITHUB_REF_NAME',
'CI_COMMIT_BRANCH',
]
NAME = [
'GITHUB_REPOSITORY',
'CI_PROJECT_PATH',
]
2024-04-27 13:32:33 +00:00
class Project:
2024-04-27 15:09:51 +00:00
def __init__(self, projects):
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-04-27 14:14:03 +00:00
self.name = path.basename(value)
2024-04-27 15:09:51 +00:00
# url
self.url = path.join(projects.url, self.name)