FOERBICO/.woodpecker/build_and_copy_website.yaml

97 lines
3.3 KiB
YAML

when:
- branch: main
event: push
path:
include: ['Website/**']
on_empty: false
steps:
- name: alpine_debug
image: alpine:3.21
commands:
- date -I'seconds'
- cat /etc/alpine-release
- which ash
- ls -la $(which ash)
- apk add --no-cache hugo
- hugo version
### bei https://hub.docker.com/_/alpine ist 3.21 "latest"
# hier in Woodpecker NICHT!!
- name: hugo-alpine
image: alpine:latest # latest ist nicht die neueste, sondern die neueste "stable" !!!
commands:
- echo "nach Docker Hub müsste >latest< Version 3.21.3 sein!"
- cat /etc/alpine-release
- apk add --no-cache hugo
- hugo version
- name: build_by_hugo
#image: alpine -- Alpine hat nur Hugo in Version hugo v0.125.4+extended linux/amd64 BuildDate=unknown // Papermod braucht >= 0.125.7
image: hugomods/hugo
commands:
- cat /etc/alpine-release
- mkdir Website/PROD
#- apk add --no-cache hugo
- hugo version
- hugo -s Website -d PROD --logLevel debug
- ls -la Website/PROD/index.html
- head Website/PROD/index.html
#- grep --version
#- grep -E . Website/PROD/index.html
#- grep -E ".*" Website/PROD/index.html
##check auf Alpine Basis!!!!
- echo $?
- which grep
# - cp Website/PROD/index.html Website/index.html
# - cp -r Website/PROD/blog Website/PROD/aprilscherz Website/
# - rm -rf Website/PROD/*
# - cp Website/index.html Website/PROD/index.html
# - cp -r Website/blog Website/aprilscherz Website/PROD/
# - grep -E "zielt FOERBICO auf die Vernetzung" Website/PROD/index.html # enthält index.html auch den Inhalt der Startseite?
# - grep -E ".*schon.mal.selbst.Materialien.erstellt.oder.arbeitest.in.einer.Community.*" Website/PROD/index.html
# - grep -E "schon" Website/PROD/index.html
# - echo $?
# #- grep -E "schon mal selbst Materialien erstellt oder arbeitest in einer Community" Website/PROD/index.html | head -n 1
# - echo $?
# - grep -E "localhost" Website/PROD/index.html # hat sich beim build ein Fehler eingeschlichen?
# - echo $?
# - grep -E 'href.+favicon.ico' Website/PROD/index.html | cut -d= -f3 # baseURL ausgeben
- name: copy_to_server
image: alpine
environment:
SSH_HOST:
from_secret: ssh_host
SSH_USER:
from_secret: ssh_user
SSH_KEY:
from_secret: ssh_key
SSH_PORT:
from_secret: ssh_port
DOMAIN_FOLDER:
from_secret: domain_folder
TARGET_PATH:
from_secret: target_path
commands:
- apk add --no-cache openssh
- mkdir -p ~/.ssh
- echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/deployKey
- chmod 600 ~/.ssh/deployKey
- ssh-keyscan -H -p $SSH_PORT $SSH_HOST 2>/dev/null >> ~/.ssh/known_hosts
- chmod 600 ~/.ssh/known_hosts
- ssh -i ~/.ssh/deployKey -p $SSH_PORT $SSH_USER@$SSH_HOST "touch $DOMAIN_FOLDER/Log/time_begin_copy_$(date +'%Y-%m-%d_%T')"
- scp -r -i ~/.ssh/deployKey -P $SSH_PORT Website/PROD/* $SSH_USER@$SSH_HOST:$DOMAIN_FOLDER/$TARGET_PATH/
- ssh -i ~/.ssh/deployKey -p $SSH_PORT $SSH_USER@$SSH_HOST "touch $DOMAIN_FOLDER/Log/time_end_copy_$(date +'%Y-%m-%d_%T')"
- name: log_end_time
image: alpine
commands:
- date -I'seconds'