From 48150b5677c2b12a0e5e51519de2d3c05a993767 Mon Sep 17 00:00:00 2001 From: Brain Date: Wed, 24 Aug 2022 23:05:00 +0200 Subject: [PATCH 1/5] Define new build pipeline --- .drone.yml | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/.drone.yml b/.drone.yml index 00f9fc1..118b658 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,46 +1,26 @@ --- kind: pipeline type: docker -name: build_webseite_main - -workspace: - path: /workspace - -steps: - - name: build - image: registry.wtf-eg.net/lektor - -image_pull_secrets: - - dockerconfig +name: build trigger: - branch: + branch: - main - event: + event: - push - ---- -kind: pipeline -type: docker -name: build_webseite_pr - -workspace: - path: /workspace + - pull_request steps: - name: build - image: registry.wtf-eg.net/lektor + image: python:3.10-bullseye + commands: + - python3 -m pip install --user pipx + - export PATH=/root/.local/bin:$PATH + - pipx install lektor + - lektor build -image_pull_secrets: - - dockerconfig - -trigger: - branch: - - main - event: - - pull_request --- kind: signature -hmac: a7c0aeda778717207ec641e7af90a358376eb3bfb22beeb67217b6d201e9e675 +hmac: aa654e71bb04571a3861f7b05550caea1b75b162d8c2710f1498a36dc5c2b8da ... From 7fa0f596adee54daffba0019ecdc98c5608af326 Mon Sep 17 00:00:00 2001 From: Brain Date: Thu, 25 Aug 2022 15:10:29 +0200 Subject: [PATCH 2/5] Add promotion steps for dev and live --- .drone.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 118b658..a4c6768 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,15 +12,59 @@ trigger: steps: - name: build - image: python:3.10-bullseye + image: python:3.10-alpine commands: + - apk add imagemagick - python3 -m pip install --user pipx - export PATH=/root/.local/bin:$PATH - pipx install lektor - lektor build +--- +kind: pipeline +type: docker +name: deploy + +trigger: + event: + - promote + +steps: + - name: deploy-live + image: python:3.10-alpine + environment: + LEKTOR_DEPLOY_KEY: + from_secret: drone_ssh_key + commands: + - apk add imagemagick + - python3 -m pip install --user pipx + - export PATH=/root/.local/bin:$PATH + - pipx install lektor + - lektor build + - apk add rsync openssh + - lektor deploy live + when: + target: + - www + - name: deploy-dev + image: python:3.10-alpine + environment: + LEKTOR_DEPLOY_KEY: + from_secret: drone_ssh_key + commands: + - apk add imagemagick + - python3 -m pip install --user pipx + - export PATH=/root/.local/bin:$PATH + - pipx install lektor + - lektor build + - apk add rsync openssh + - lektor deploy dev + when: + target: + - spielwiese + --- kind: signature -hmac: aa654e71bb04571a3861f7b05550caea1b75b162d8c2710f1498a36dc5c2b8da +hmac: 8ddcd8d284e6a0e19b9ef6456c9fe12ebaacaa1d639f1008b5a4527a4026d1b0 ... From 89f46989d9e7dd439ab498f3d9e8a1e636e01d28 Mon Sep 17 00:00:00 2001 From: Brain Date: Thu, 25 Aug 2022 15:22:48 +0200 Subject: [PATCH 3/5] Add www to known hosts --- .drone.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index a4c6768..d350c66 100644 --- a/.drone.yml +++ b/.drone.yml @@ -42,6 +42,7 @@ steps: - pipx install lektor - lektor build - apk add rsync openssh + - echo "www.wtf-eg.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICBp7eSOC07exvXuY4XhpZOuXax+zyzoymSVD4/+D/P6" >> ~/.ssh/known_hosts - lektor deploy live when: target: @@ -58,6 +59,7 @@ steps: - pipx install lektor - lektor build - apk add rsync openssh + - echo "www.wtf-eg.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICBp7eSOC07exvXuY4XhpZOuXax+zyzoymSVD4/+D/P6" >> ~/.ssh/known_hosts - lektor deploy dev when: target: @@ -65,6 +67,6 @@ steps: --- kind: signature -hmac: 8ddcd8d284e6a0e19b9ef6456c9fe12ebaacaa1d639f1008b5a4527a4026d1b0 +hmac: 2de977d0e1dd5584f901284e7d71a96bb14e205e9de67724ca631e57d357c17f ... From e5ae098d6f2fee15bec6293caa099b6771e86601 Mon Sep 17 00:00:00 2001 From: Brain Date: Thu, 25 Aug 2022 15:28:39 +0200 Subject: [PATCH 4/5] Fix deployment issue --- .drone.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index d350c66..5dcbabf 100644 --- a/.drone.yml +++ b/.drone.yml @@ -42,6 +42,7 @@ steps: - pipx install lektor - lektor build - apk add rsync openssh + - mkdir ~/.ssh - echo "www.wtf-eg.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICBp7eSOC07exvXuY4XhpZOuXax+zyzoymSVD4/+D/P6" >> ~/.ssh/known_hosts - lektor deploy live when: @@ -59,6 +60,7 @@ steps: - pipx install lektor - lektor build - apk add rsync openssh + - mkdir ~/.ssh - echo "www.wtf-eg.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICBp7eSOC07exvXuY4XhpZOuXax+zyzoymSVD4/+D/P6" >> ~/.ssh/known_hosts - lektor deploy dev when: @@ -67,6 +69,6 @@ steps: --- kind: signature -hmac: 2de977d0e1dd5584f901284e7d71a96bb14e205e9de67724ca631e57d357c17f +hmac: 1d3d4b3f8845995c06e246c3874c98b5ae9ef2cb50ed3bf382942f52038eb784 ... From 096ec0aaf708276f5377895f6c6006b33e04361a Mon Sep 17 00:00:00 2001 From: Brain Date: Thu, 25 Aug 2022 18:42:56 +0200 Subject: [PATCH 5/5] Add deployment docs --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 5469399..89604c1 100644 --- a/README.md +++ b/README.md @@ -62,3 +62,24 @@ export GIT_LFS_SKIP_SMUDGE=1 git clone ``` *(Da das Rendern der Startseite die Bilder benötigt, willst du dann im lektor direkt auf eine andere Unterseite wechseln. Die Seite [http://localhost:5000/admin/](http://localhost:5000/admin/) sollte nützlich sein!)* + +## Deployment + +### Per Drone + +Drone testet bereits automatisch den eingecheckten Code im `main`-Branch und für Pull Requests. +Deployments finden nicht automatisch statt, sondern müssen angestoßen werden. + +Wähle dazu den erfolgreichen Build, den du deployen möchtest unter https://drone.wtf-eg.de/ag_kommunikation/webseite aus. +Rechts oben findest du dann einen Knopf zum Deployment (Wolke mit Pfeil). +Als Environment kannst du _spielwiese_ oder _www_ verwenden. + +### Per Hand +Das Deployment sollte für maximale Reproduzierbarkeit und Nachvollziehbarkeit immer über Drone stattfinden. +In Ausnahmesituationen kann jedoch ein manuelles Deployment nötig sein. + +```bash +lektor build +lektor deploy dev # Deployment auf die Spielwiese +lektor deploy live # Deployment auf die Live-Seite +```