From 9e8dd694d91fe5709bffd53d3c5726e4e8f37c5c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 1 Jun 2024 15:25:23 +0200 Subject: [PATCH] synchronize/wip --- .forgejo/workflows/debian:bookworm.yaml | 2 +- cd/__init__.py | 19 +++++++++++++++++++ cmd/cd-synchronize.sh | 23 ----------------------- 3 files changed, 20 insertions(+), 24 deletions(-) delete mode 100755 cmd/cd-synchronize.sh diff --git a/.forgejo/workflows/debian:bookworm.yaml b/.forgejo/workflows/debian:bookworm.yaml index 976d9ae..776457b 100644 --- a/.forgejo/workflows/debian:bookworm.yaml +++ b/.forgejo/workflows/debian:bookworm.yaml @@ -13,4 +13,4 @@ jobs: - run: cd-clone-branch - run: cd-build-project - run: cd-browse-workspace - - run: cd-synchronize out + - run: cd-synchronize diff --git a/cd/__init__.py b/cd/__init__.py index ac39077..b2cc47a 100644 --- a/cd/__init__.py +++ b/cd/__init__.py @@ -55,6 +55,24 @@ def cd_list_environment(): print(variable, '=', value) +def cd_synchronize(): + sync_host = 'rwx.work' + sync_source = 'out' + sync_user = 'cd' + # + sync_root = f'/{sync_user}/{project.branch}/{project.name}' + # + sync_target = f'{sync_user}@{sync_host}:{sync_root}' + ps.run('rsync', + '--archive', + '--delete-before', + '--verbose', + f'{sync_source}/', + f'{sync_target}/', + '--dry-run', + ) + + def install_commands(path): user = '/usr/local/bin' for command in [ @@ -62,6 +80,7 @@ def install_commands(path): 'build-project', 'clone-branch', 'list-environment', + 'synchronize', ]: print(command) os.symlink(path, os.path.join(user, f'{COMMANDS_PREFIX}{command}')) diff --git a/cmd/cd-synchronize.sh b/cmd/cd-synchronize.sh deleted file mode 100755 index 437df02..0000000 --- a/cmd/cd-synchronize.sh +++ /dev/null @@ -1,23 +0,0 @@ -[ "${1}" ] && SYNC_SOURCE="${1}" || exit - -SYNC_USER='cd' - -[ "${GITHUB_SERVER_URL}" ] \ -&& SYNC_HOST="$(basename ${GITHUB_SERVER_URL})" || exit - -[ "${SYNC_USER}" ] \ -&& SYNC_ROOT="/${SYNC_USER}" || exit -[ "${GITHUB_REF_NAME}" ] \ -&& SYNC_ROOT="${SYNC_ROOT}/${GITHUB_REF_NAME}" || exit -[ "${GITHUB_REPOSITORY}" ] \ -&& SYNC_ROOT="${SYNC_ROOT}/${GITHUB_REPOSITORY}" || exit - -SYNC_TARGET="${SYNC_USER}@${SYNC_HOST}:${SYNC_ROOT}" -[ "${2}" ] && SYNC_TARGET="${SYNC_TARGET}/${2}" - -rsync \ ---archive \ ---delete-before \ ---verbose \ -"${SYNC_SOURCE}/" \ -"${SYNC_TARGET}/"