Skip to content

Commit

Permalink
[ci] reflect changes in ci-repo-deploy script
Browse files Browse the repository at this point in the history
create target dir debian with conf directory
  • Loading branch information
nqb committed May 31, 2021
1 parent 0ba7909 commit d1d50e8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
4 changes: 1 addition & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ variables:
variables:
DEPLOY_USER: reposync
DEPLOY_HOST: web.inverse.ca
# DEPLOY_UPDATE: "FIXME"
script:
- ./${UPLOAD_DIR}/deploy-artifacts.sh deb
tags:
Expand All @@ -209,7 +208,6 @@ variables:
DEPLOY_USER: reposync
DEPLOY_HOST: web.inverse.ca
DEPLOY_SRPMS: "no"
# DEPLOY_UPDATE: "FIXME"
script:
- ./${UPLOAD_DIR}/deploy-artifacts.sh rpm
tags:
Expand Down Expand Up @@ -623,7 +621,7 @@ deploy_deb_release:
- .deploy_deb_job
- .job_release_triggers
environment:
name: release
name: stable
variables:
DEB_DEPLOY_DIR: debian

Expand Down
28 changes: 21 additions & 7 deletions ci/lib/upload/deploy-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ RESULT_DIR=${RESULT_DIR:-result}

DEPLOY_USER=${DEPLOY_USER:-reposync}
DEPLOY_HOST=${DEPLOY_HOST:-web.inverse.ca}
DEPLOY_UPDATE=${DEPLOY_UPDATE:-"hostname -f"}

#REPO_BASE_DIR=${REPO_BASE_DIR:-/var/www/repos/PacketFence}
PUBLIC_REPO_BASE_DIR=${PUBLIC_REPO_BASE_DIR:-/var/www/inverse.ca/downloads/PacketFence}

# RPM
Expand All @@ -30,21 +28,27 @@ RPM_RESULT_DIR=${RPM_RESULT_DIR:-"${RESULT_DIR}/centos"}

# Deb
DEB_UPLOAD_DIR=${DEB_UPLOAD_DIR:-"${HOME}/debian/UploadQueue"}
DEB_BASE_DIR=${DEB_BASE_DIR:-"${PUBLIC_REPO_BASE_DIR}"}
DEB_DEPLOY_DIR=${DEB_DEPLOY_DIR:-foo}
DEB_RESULT_DIR=${DEB_RESULT_DIR:-"${RESULT_DIR}/debian"}

# Maintenance
MAINT_DEPLOY_DIR=${MAINT_DEPLOY_DIR:-tmp}

# CI
# automatically set up by CI based on environment
CI_ENV_NAME=${CI_ENVIRONMENT_NAME:-environment}

rpm_deploy() {
for release_name in $(ls $RPM_RESULT_DIR); do
src_dir="$RPM_RESULT_DIR/${release_name}"
dst_repo="$RPM_BASE_DIR/RHEL$release_name/$RPM_DEPLOY_DIR/RPMS"
dst_dir="$DEPLOY_USER@$DEPLOY_HOST:$dst_repo"
deploy_cmd="/usr/local/bin/ci-repo-deploy rpm $dst_repo $CI_ENV_NAME"
declare -p src_dir dst_dir

# dest repo need to exist
mkdir_cmd="$DEPLOY_USER@$DEPLOY_HOST mkdir -p $dst_repo"
# dest repo need to exist + conf directories
mkdir_cmd="$DEPLOY_USER@$DEPLOY_HOST mkdir -p $dst_repo/conf"
echo "running following command: $mkdir_cmd"
ssh $mkdir_cmd \
|| die "remote mkdir failed"
Expand All @@ -62,7 +66,7 @@ rpm_deploy() {
|| die "scp failed"

# update repository
dst_cmd="$DEPLOY_USER@$DEPLOY_HOST $DEPLOY_UPDATE"
dst_cmd="$DEPLOY_USER@$DEPLOY_HOST $deploy_cmd"
echo "running following command: $dst_cmd"
ssh $dst_cmd \
|| die "update failed"
Expand All @@ -72,14 +76,23 @@ rpm_deploy() {
deb_deploy() {
for release_name in $(ls $DEB_RESULT_DIR); do
src_dir="$DEB_RESULT_DIR/${release_name}"
dst_repo="$DEB_BASE_DIR/$DEB_DEPLOY_DIR/$PF_MINOR_RELEASE"
dst_dir="$DEPLOY_USER@$DEPLOY_HOST:$DEB_UPLOAD_DIR"
changes_file=$(basename $(ls $DEB_RESULT_DIR/${release_name}/*.changes | tail -1))
declare -p src_dir dst_dir changes_file

# dest repo need to exist
mkdir_cmd="$DEPLOY_USER@$DEPLOY_HOST mkdir -p $dst_repo"
echo "running following command: $mkdir_cmd"
ssh $mkdir_cmd \
|| die "remote mkdir failed"

echo "copy: $src_dir/* -> $dst_dir"
scp $src_dir/* $dst_dir/ \
|| die "scp failed"

dst_cmd="$DEPLOY_USER@$DEPLOY_HOST $DEPLOY_UPDATE"

deploy_cmd="/usr/local/bin/ci-repo-deploy deb $dst_repo $CI_ENV_NAME"
dst_cmd="$DEPLOY_USER@$DEPLOY_HOST $deploy_cmd"
extra_args="${release_name} ${changes_file}"
echo "running following command: $dst_cmd $extra_args"
ssh $dst_cmd $extra_args \
Expand All @@ -98,6 +111,7 @@ maint_deploy() {
|| die "scp failed"
}

# no deploy command because it's just a file
packetfence_release_el8_deploy() {
src_dir="$RPM_RESULT_DIR/8"
dst_repo="$PUBLIC_REPO_BASE_DIR/RHEL8"
Expand Down

0 comments on commit d1d50e8

Please sign in to comment.