spcd/cd/cd-synchronize

24 lines
561 B
Text
Raw Normal View History

2024-03-23 12:07:20 +00:00
[ "${1}" ] && SYNC_SOURCE="${1}" || exit
2024-03-23 11:20:52 +00:00
SYNC_USER='cd'
2024-03-23 12:07:20 +00:00
[ "${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
2024-03-23 11:20:52 +00:00
SYNC_TARGET="${SYNC_USER}@${SYNC_HOST}:${SYNC_ROOT}"
2024-03-23 12:07:20 +00:00
[ "${2}" ] && SYNC_TARGET="${SYNC_TARGET}/${2}"
2024-03-23 11:20:52 +00:00
2024-03-23 12:15:17 +00:00
rsync \
--archive \
--delete-before \
--verbose \
"${SYNC_SOURCE}/" \
"${SYNC_TARGET}/"