Skip to contentSkip to conversation

deploy to qemu-project.org from GitLab CI

PATCH In review Paolo Bonzini 2 participants 2 messages Jan 19, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 deploy to qemu-project.org from GitLab CI

Currently, the website is rebuilt on qemu-project.org using an update hook. We can reuse instead the Jekyll output of GitLab's CI.

To do so, a new user qemu-deploy has been created on qemu.org. The private key is stored into a file variable SSH_PRIVATE_KEY_FILE (be careful to include the trailing newline after "---END OPENSSH PRIVATE KEY---"!).

---
 .gitlab-ci.yml | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
.gitlab-ci.yml +28 -0
index 5fa3041..129b2ff 100644
@@ -1,6 +1,11 @@
 
+stages:
+  - build
+  - update
+
 pages:
   image: centos:8
+  stage: build
   cache:
     paths:
       - vendor
@@ -14,3 +19,26 @@ pages:
   artifacts:
     paths:
      - public
+
+deploy:
+  image: centos:8
+  stage: update
+  needs:
+    - job: pages
+      artifacts: true
+  before_script:
+    - dnf install -y openssh-clients rsync
+    - eval $(ssh-agent -s)
+    - cat "$SSH_PRIVATE_KEY_FILE" | tr -d '\r' | ssh-add -
+    - mkdir -m700 -p ~/.ssh
+    - - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'
+  script:
+    - ssh $SSH_DEPLOY_DESTINATION "cd /var/www/qemu-project.org && mkdir new && rsync -az root/ new"
+    - rsync -avz --delete public/ $SSH_DEPLOY_DESTINATION:/var/www/qemu-project.org/new
+    - ssh $SSH_DEPLOY_DESTINATION "cd /var/www/qemu-project.org && rm -rf old && mv root old && mv new root"
+  only:
+    refs:
+      - master
+    variables:
+      - $SSH_PRIVATE_KEY_FILE
+      - $SSH_DEPLOY_DESTINATION
Signature · 1 line
2.29.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 47 lines · Paolo Bonzini

Currently, the website is rebuilt on qemu-project.org using an update hook. We can reuse instead the Jekyll output of GitLab's CI.

To do so, a new user qemu-deploy has been created on qemu.org. The private key is stored into a file variable SSH_PRIVATE_KEY_FILE (be careful to include the trailing newline after "---END OPENSSH PRIVATE KEY---"!).

---
 .gitlab-ci.yml | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
.gitlab-ci.yml +18 -0
index 5fa3041..129b2ff 100644
@@ -1,6 +1,11 @@
 
+stages:
+  - build
+  - update
+
 pages:
   image: centos:8
+  stage: build
   cache:
     paths:
       - vendor
@@ -14,3 +19,26 @@ pages:
   artifacts:
     paths:
      - public
+
+deploy:
+  image: centos:8
+  stage: update
+  needs:
+    - job: pages
+      artifacts: true
+  before_script:
+    - dnf install -y openssh-clients rsync
+    - eval $(ssh-agent -s)
+    - cat "$SSH_PRIVATE_KEY_FILE" | tr -d '\r' | ssh-add -
+    - mkdir -m700 -p ~/.ssh
+    - - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'

.gitlab-ci.yml pages: · line 44

Quoted 10 lines
.gitlab-ci.yml +10 -0
+  script:
+    - ssh $SSH_DEPLOY_DESTINATION "cd /var/www/qemu-project.org && mkdir new && rsync -az root/ new"
+    - rsync -avz --delete public/ $SSH_DEPLOY_DESTINATION:/var/www/qemu-project.org/new
+    - ssh $SSH_DEPLOY_DESTINATION "cd /var/www/qemu-project.org && rm -rf old && mv root old && mv new root"
+  only:
+    refs:
+      - master
+    variables:
+      - $SSH_PRIVATE_KEY_FILE
+      - $SSH_DEPLOY_DESTINATION

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|