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-05-29 22:21:42 +00:00
|
|
|
ROOT = [
|
|
|
|
'GITHUB_WORKSPACE',
|
|
|
|
'CI_PROJECT_DIR',
|
|
|
|
]
|
2024-04-27 14:14:03 +00:00
|
|
|
|
|
|
|
|
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-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
|
|
|
|
self.url = path.join(projects.url, self.name)
|