spcd/cd/project.py
Marc Beninca e191f3cc4d
Some checks failed
/ job (push) Has been cancelled
browse-workspace
2024-05-30 00:21:42 +02:00

33 lines
805 B
Python

from os import path
BRANCH = [
'GITHUB_REF_NAME',
'CI_COMMIT_BRANCH',
]
NAME = [
'GITHUB_REPOSITORY',
'CI_PROJECT_PATH',
]
ROOT = [
'GITHUB_WORKSPACE',
'CI_PROJECT_DIR',
]
class Project:
def __init__(self, projects):
self.projects = projects
# branch
for variable in BRANCH:
if value := projects.environment.get(variable, None):
self.branch = value
# name
for variable in NAME:
if value := projects.environment.get(variable, None):
self.name = path.basename(value)
# root
for variable in ROOT:
if value := projects.environment.get(variable, None):
self.root = value
# url
self.url = path.join(projects.url, self.name)