Verified Commit e99fc031 authored by anarcat's avatar anarcat
Browse files

move deploy stage to the template (team#40364)

parent 3cdeec30
Pipeline #18574 passed with stages
in 41 seconds
......@@ -14,6 +14,10 @@ variables:
SITE_URL: status.torproject.org
SUBDIR: public/
include:
project: tpo/tpa/ci-templates
file: static-shim-deploy.yml
build:
stage: build
script:
......@@ -34,34 +38,3 @@ pages:
- public
only:
- merge_requests
# reuses artifacts from the previous (build) stage
deploy-static:
image: debian:stable-slim
stage: deploy
resource_group: static-component-$SITE_URL
script:
# the printf stuff below is https://docs.gitlab.com/ee/ci/jobs/index.html#custom-collapsible-sections
- printf '\e[0Ksection_start:%s:apt_setup\r\e[0K\e[36minstall requirements with apt\e[0m\n' "$(date +%s)"
- apt update
- apt-get dist-upgrade --yes --no-install-recommends --no-install-suggests
- apt-get install --yes --no-install-recommends --no-install-suggests openssh-client rsync
- printf '\e[0Ksection_end:%s:apt_setup\r\e[0K\n' "$(date +%s)"
- printf '\e[0Ksection_start:%s:ssh_cleanup\r\e[0K\e[36mbuilding a fake .ssh directory to fixup perms, because that cannot be done on the files from variables\e[0m\n' "$(date +%s)"
- mkdir .ssh
- cp "$STATIC_GITLAB_SHIM_SSH_PRIVATE_KEY" .ssh/private_key
- cp "$STATIC_GITLAB_SHIM_SSH_HOST_KEYS" .ssh/known_hosts
- chmod 400 .ssh/known_hosts .ssh/private_key
- echo "variables often lack a trailing newline, which breaks SSH, detect and fix"
- ssh-keygen -y -f .ssh/private_key || echo >> .ssh/private_key
- echo "here is the SSH key we will deploy with"
- ssh-keygen -y -f .ssh/private_key
- printf '\e[0Ksection_end:%s:ssh_cleanup\r\e[0K\n' "$(date +%s)"
- printf '\e[0Ksection_start:%s:rsync\r\e[0K\e[36mrunning rsync\e[0m\n' "$(date +%s)"
- rsync --rsh="ssh -o UserKnownHostsFile=.ssh/known_hosts -i .ssh/private_key" --checksum --archive --verbose --delete "$SUBDIR" static-gitlab-shim@static-gitlab-shim.torproject.org:"$SUBDIR"
- printf '\e[0Ksection_end:%s:rsync\r\e[0K\n' "$(date +%s)"
- printf '\e[0Ksection_start:%s:static-component\r\e[0K\e[36mrunning static-update-component\e[0m\n' "$(date +%s)"
- ssh -o UserKnownHostsFile=".ssh/known_hosts" -i ".ssh/private_key" static-gitlab-shim@static-gitlab-shim.torproject.org static-update-component "$SITE_URL"
- printf '\e[0Ksection_end:%s:static-component\r\e[0K\n' "$(date +%s)"
only:
- main
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment