From 5ae4068bec16cdc456973840130104db6261f2e7 Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Sat, 2 Mar 2024 09:25:24 +0100 Subject: [PATCH] ADD: started ci/cd --- .container/Containerfile | 5 ++ .drone.yml | 92 +++++++++++++++++++++++++++++++++++++ scripts/generate_control.sh | 30 ++++++++++++ scripts/setupEnvironment.sh | 3 ++ 4 files changed, 130 insertions(+) create mode 100644 .container/Containerfile create mode 100644 .drone.yml create mode 100755 scripts/generate_control.sh create mode 100755 scripts/setupEnvironment.sh diff --git a/.container/Containerfile b/.container/Containerfile new file mode 100644 index 0000000..8437439 --- /dev/null +++ b/.container/Containerfile @@ -0,0 +1,5 @@ +FROM nginx + +COPY FHEM /usr/share/nginx/html +COPY controls_byterazor-fhem-ntfy /usr/share/nginx/html/ +COPY CHANGED /usr/share/nginx/html/ diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..cf0465e --- /dev/null +++ b/.drone.yml @@ -0,0 +1,92 @@ +kind: pipeline +type: kubernetes +name: build-amd64 +platform: + arch: amd64 +node_selector: + kubernetes.io/arch: amd64 + +volumes: +- name: fedhq-ca-crt + config_map: + name: fedhq-ca-crt + default_mode: 420 # same as 644 in octal, or u+w,a+r + optional: false + +steps: + - name: generate control + image: debian:bookworm + commands: + - scripts/generate_control.sh + + - name: build amd64 + image: quay.io/buildah/stable + privileged: true + volumes: + - name: fedhq-ca-crt + path: /etc/ssl/certs2/ + commands: + - scripts/setupEnvironment.sh + - buildah bud -t "registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-amd64" --arch amd64 .container/ + - buildah push --all registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-amd64 +--- +kind: pipeline +type: kubernetes +name: build-arm64 +platform: + arch: arm64 +node_selector: + kubernetes.io/arch: arm64 + +volumes: +- name: fedhq-ca-crt + config_map: + name: fedhq-ca-crt + default_mode: 420 # same as 644 in octal, or u+w,a+r + optional: false + +steps: + - name: generate control + image: debian:bookworm + commands: + - scripts/generate_control.sh + + - name: build arm64 + image: quay.io/buildah/stable + privileged: true + volumes: + - name: fedhq-ca-crt + path: /etc/ssl/certs2/ + commands: + - scripts/setupEnvironment.sh + - buildah bud -t "registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-arm64" --arch arm64 ./container/ + - buildah push --all registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-arm64 +--- +kind: pipeline +type: kubernetes +name: push +node_selector: + kubernetes.io/arch: amd64 + +volumes: +- name: fedhq-ca-crt + config_map: + name: fedhq-ca-crt + default_mode: 420 # same as 644 in octal, or u+w,a+r + optional: false + +steps: + - name: push + image: quay.io/buildah/stable + privileged: true + volumes: + - name: fedhq-ca-crt + path: /etc/ssl/certs2/ + commands: + - scripts/setupEnvironment.sh + - buildah manifest create nginx-fhem-ntfy:latest registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-arm64 registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-amd64 + - buildah manifest push --all nginx-fhem-ntfy:latest docker://registry.cloud.federationhq.de/nginx-fhem-ntfy:latest + - buildah manifest rm nginx-fhem-ntfy:latest +depends_on: + - build-amd64 + - build-arm64 \ No newline at end of file diff --git a/scripts/generate_control.sh b/scripts/generate_control.sh new file mode 100755 index 0000000..97f60e1 --- /dev/null +++ b/scripts/generate_control.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +CONTROL_FILE="controls_byterazor-fhem-ntfy.txt" + +if [ -e $CONTROL_FILE ]; then + rm $CONTROL_FILE +fi + +find ./FHEM -type f \( ! -iname "0.*" \) -print0 | while IFS= read -r -d '' f; +do + out="UPD $(stat --format "%z %s" $f | sed -e "s#\([0-9-]*\)\ \([0-9:]*\)\.[0-9]*\ [+0-9]*#\1_\2#") $f" + echo "${out//.\//}" >> $CONTROL_FILE +done + + +#generate CHANGELOG +rm CHANGED +DATE= +git log --no-merges --pretty=format:'%ci|%s' | while read -r line; do + CDATE=$(echo "${line}" | awk '{print $1}') + MSG=$(echo "${line}" | awk -F '|' '{print $2}') + + if [ "$DATE" != "$CDATE" ]; then + DATE=$CDATE + echo "$DATE" >> CHANGED + fi + + echo " ${MSG}" >> CHANGED + +done diff --git a/scripts/setupEnvironment.sh b/scripts/setupEnvironment.sh new file mode 100755 index 0000000..2761ce0 --- /dev/null +++ b/scripts/setupEnvironment.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cp /etc/ssl/certs2/federationHQ-CA.pem /etc/pki/ca-trust/source/anchors/ +update-ca-trust