parent
568943f176
commit
afffb8c90f
2 changed files with 34 additions and 1 deletions
18
cd.sh
18
cd.sh
|
@ -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
|
||||
|
|
|
@ -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}'))
|
||||
|
|
Loading…
Reference in a new issue