clone_branch
Some checks failed
/ job (push) Failing after 6s

This commit is contained in:
Marc Beninca 2024-04-27 01:10:30 +02:00
parent 568943f176
commit afffb8c90f
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 34 additions and 1 deletions

18
cd.sh
View file

@ -27,6 +27,7 @@ case "${CD_OS_NAME}" in
exit 1
;;
esac
#
[ "${CI_SERVER_URL}" ] && CD_REPOSITORIES_URL="${CI_SERVER_URL}"
[ "${GITHUB_SERVER_URL}" ] && CD_REPOSITORIES_URL="${GITHUB_SERVER_URL}"
if [ "${CD_REPOSITORIES_URL}" ] ; then
@ -35,6 +36,23 @@ else
echo 'CD_REPOSITORIES_URL'
exit 3
fi
#
[ "${CI_PROJECT_NAME}" ] && CD_PROJECT_NAME="${CI_PROJECT_NAME}"
[ "${GITHUB_REPOSITORY}" ] \
&& CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
if [ "${CD_PROJECT_NAME}" ] ; then
CD_PROJECT_URL="${CD_REPOSITORIES_URL}/${CD_PROJECT_NAME}"
else
echo 'CD_PROJECT_NAME'
exit 3
fi
#
[ "${CI_COMMIT_BRANCH}" ] && CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
[ "${GITHUB_REF_NAME}" ] && CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
if [ ! "${CD_PROJECT_BRANCH}" ] ; then
echo 'CD_PROJECT_BRANCH'
exit 3
fi
function cd_step {
if [ "${1}" ] ; then

View file

@ -1,8 +1,20 @@
import os
from rwx import ps
COMMANDS_PREFIX = 'cd-'
def cd_clone_branch():
ps.run('git',
'clone',
'--branch', os.environ['CD_PROJECT_BRANCH'],
'--',
os.environ['CD_PROJECT_URL'],
'.',
)
def cd_list_environment():
for variable, value in sorted(os.environ.items()):
print(variable, '=', value)
@ -10,5 +22,8 @@ def cd_list_environment():
def install_commands(path):
user = '/usr/local/bin'
for command in ['list-environment']:
for command in [
'clone-branch',
'list-environment',
]:
os.symlink(path, os.path.join(user, f'{COMMANDS_PREFIX}{command}'))