Add deploy preflight checks
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
index.html
|
||||
datenschutz.html
|
||||
impressum.html
|
||||
robots.txt
|
||||
sitemap.xml
|
||||
css
|
||||
img
|
||||
vendor
|
||||
+37
-8
@@ -4,6 +4,7 @@ set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
config_file="$repo_root/.deploy.env"
|
||||
include_file="${DEPLOY_INCLUDE_FILE:-$repo_root/scripts/deploy-include.txt}"
|
||||
|
||||
if [[ ! -f "$config_file" ]]; then
|
||||
echo "Fehlende Konfiguration: $config_file" >&2
|
||||
@@ -16,6 +17,11 @@ if ! command -v sftp >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$include_file" ]]; then
|
||||
echo "Fehlende Deploy-Liste: $include_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -a
|
||||
source "$config_file"
|
||||
set +a
|
||||
@@ -26,24 +32,47 @@ set +a
|
||||
|
||||
deploy_port="${DEPLOY_PORT:-22}"
|
||||
batch_file="$(mktemp)"
|
||||
deploy_items=()
|
||||
cleanup() {
|
||||
rm -f "$batch_file"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
while IFS= read -r raw_item || [[ -n "$raw_item" ]]; do
|
||||
item="${raw_item%%#*}"
|
||||
item="${item%${item##*[![:space:]]}}"
|
||||
item="${item#${item%%[![:space:]]*}}"
|
||||
|
||||
if [[ -z "$item" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ ! -e "$repo_root/$item" ]]; then
|
||||
echo "Fehlender Deploy-Eintrag: $item" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
deploy_items+=("$item")
|
||||
done < "$include_file"
|
||||
|
||||
if [[ ${#deploy_items[@]} -eq 0 ]]; then
|
||||
echo "Keine Deploy-Eintraege in $include_file gefunden." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > "$batch_file" <<EOF
|
||||
-mkdir $DEPLOY_TARGET_DIR
|
||||
cd $DEPLOY_TARGET_DIR
|
||||
put index.html
|
||||
put datenschutz.html
|
||||
put impressum.html
|
||||
put robots.txt
|
||||
put sitemap.xml
|
||||
put -r css
|
||||
put -r img
|
||||
put -r vendor
|
||||
EOF
|
||||
|
||||
for item in "${deploy_items[@]}"; do
|
||||
if [[ -d "$repo_root/$item" ]]; then
|
||||
printf 'put -r %s\n' "$item" >> "$batch_file"
|
||||
else
|
||||
printf 'put %s\n' "$item" >> "$batch_file"
|
||||
fi
|
||||
done
|
||||
|
||||
cd "$repo_root"
|
||||
sftp -P "$deploy_port" "$DEPLOY_USER@$DEPLOY_HOST" < "$batch_file"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user