Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Commit c2407bc

Browse files
Webseiten-Upload: Fehlermeldung direkt im Lauf anzeigen (#68)
* Upload: Fehlermeldung von lftp als Annotation anzeigen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NsC5RADQbU18ZDp4dq4M4L * Upload: automatisch SFTP oder FTPS wählen, Zeilenumbrüche in Secrets ignorieren Der Trockenlauf gegen All-Inkl scheiterte per SFTP mit „Login incorrect“. SFTP gibt es dort nur mit SSH-Zugang, FTP-Benutzer melden sich per FTPS an. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NsC5RADQbU18ZDp4dq4M4L * Upload per FTPS, Zielordner automatisch erkennen Der Trockenlauf zeigt: FTPS-Anmeldung klappt, der FTP-Benutzer startet aber schon im Webseiten-Ordner. Ohne DEPLOY_DIR wird jetzt visustruct.org oder der Startordner genommen, aber nur, wenn dort die VisuStruct-Seite liegt. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NsC5RADQbU18ZDp4dq4M4L --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7e2eee8 commit c2407bc

3 files changed

Lines changed: 75 additions & 23 deletions

File tree

‎.github/scripts/deploy-website.sh‎

Lines changed: 71 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Lädt den Ordner website/ per SFTP (oder FTPS) zu All-Inkl hoch.
2+
# Lädt den Ordner website/ per FTPS (oder SFTP) zu All-Inkl hoch.
33
#
44
# Auf dem Server wird nur gelöscht, was ein früherer Lauf dieses Skripts selbst
55
# hochgeladen hat (Liste in .visustruct-deploy-manifest.txt im Zielordner), und
@@ -8,44 +8,96 @@
88
#
99
# Umgebung:
1010
# DEPLOY_HOST, DEPLOY_USER, LFTP_PASSWORD Pflicht
11-
# DEPLOY_PROTOCOL sftp (Standard) oder ftps
12-
# DEPLOY_DIR Zielordner relativ zum Login, Standard visustruct.org
13-
# ("." wenn der FTP-Benutzer direkt in diesem Ordner landet)
11+
# DEPLOY_PROTOCOL auto (Standard: erst SFTP, dann FTPS), sftp oder ftps
12+
# DEPLOY_DIR Zielordner relativ zum Login; ohne Angabe visustruct.org
13+
# oder der Startordner, je nachdem, wo die Webseite liegt
1414
# SOURCE_DIR Standard website
1515
# DRY_RUN=1 nur anzeigen, nichts hochladen oder löschen
1616
set -euo pipefail
1717

18+
# Beim Einfügen ins Secret-Feld rutscht leicht ein Zeilenumbruch mit hinein
19+
DEPLOY_USER="$(printf '%s' "${DEPLOY_USER:-}" | tr -d '\r\n' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')"
20+
LFTP_PASSWORD="$(printf '%s' "${LFTP_PASSWORD:-}" | tr -d '\r\n')"
1821
: "${DEPLOY_HOST:?DEPLOY_HOST fehlt}"
1922
: "${DEPLOY_USER:?DEPLOY_USER fehlt}"
2023
: "${LFTP_PASSWORD:?LFTP_PASSWORD fehlt}"
2124
export LFTP_PASSWORD
2225

23-
PROTOCOL="${DEPLOY_PROTOCOL:-sftp}"
24-
REMOTE_DIR="${DEPLOY_DIR:-visustruct.org}"
26+
PROTOCOL="${DEPLOY_PROTOCOL:-auto}"
27+
REMOTE_DIR="${DEPLOY_DIR:-}"
2528
SOURCE_DIR="${SOURCE_DIR:-website}"
2629
DRY_RUN="${DRY_RUN:-0}"
2730
MANIFEST=".visustruct-deploy-manifest.txt"
2831

2932
case "$REMOTE_DIR" in
30-
""|"/"|"~"|*..*|*'"'*) echo "Ungültiger Zielordner: '$REMOTE_DIR'" >&2; exit 1 ;;
33+
"/"|"~"|*..*|*'"'*) echo "Ungültiger Zielordner: '$REMOTE_DIR'" >&2; exit 1 ;;
3134
esac
3235
[ -f "$SOURCE_DIR/index.html" ] || { echo "$SOURCE_DIR/index.html fehlt" >&2; exit 1; }
3336

34-
case "$PROTOCOL" in
35-
sftp) URL="sftp://$DEPLOY_HOST"
36-
SETTINGS="set sftp:auto-confirm yes" ;;
37-
ftps) URL="ftp://$DEPLOY_HOST"
38-
SETTINGS="set ftp:ssl-force true; set ftp:ssl-protect-data true; set ssl:verify-certificate ${DEPLOY_VERIFY_CERT:-yes}" ;;
39-
*) echo "DEPLOY_PROTOCOL muss sftp oder ftps sein" >&2; exit 1 ;;
40-
esac
41-
4237
work="$(mktemp -d)"
4338
trap 'rm -rf "$work"' EXIT
4439

45-
connect="$SETTINGS; set net:max-retries 3; set net:timeout 30; set cmd:fail-exit yes
46-
open --env-password -u \"$DEPLOY_USER\" $URL
40+
connect_for() {
41+
local url settings
42+
case "$1" in
43+
sftp) url="sftp://$DEPLOY_HOST"
44+
settings="set sftp:auto-confirm yes" ;;
45+
ftps) url="ftp://$DEPLOY_HOST"
46+
settings="set ftp:ssl-force true; set ftp:ssl-protect-data true; set ssl:verify-certificate ${DEPLOY_VERIFY_CERT:-yes}" ;;
47+
*) echo "DEPLOY_PROTOCOL muss auto, sftp oder ftps sein" >&2; exit 1 ;;
48+
esac
49+
printf '%s' "$settings; set net:max-retries 3; set net:timeout 30; set cmd:fail-exit yes
50+
open --env-password -u \"$DEPLOY_USER\" $url"
51+
}
52+
53+
# auto: SFTP versuchen, bei All-Inkl geht das nur mit SSH-Zugang; sonst FTPS
54+
if [ "$PROTOCOL" = "auto" ]; then
55+
for p in sftp ftps; do
56+
if lftp -c "$(connect_for $p); cls -1 >/dev/null" 2> "$work/probe-$p"; then
57+
PROTOCOL=$p; break
58+
fi
59+
echo "$p: $(grep -v '^$' "$work/probe-$p" | tail -n 1)" >&2
60+
done
61+
if [ "$PROTOCOL" = "auto" ]; then
62+
echo "::error::Anmeldung fehlgeschlagen. SFTP: $(grep -v '^$' "$work/probe-sftp" | tail -n 1) FTPS: $(grep -v '^$' "$work/probe-ftps" | tail -n 1)"
63+
exit 1
64+
fi
65+
fi
66+
echo "Verbindung über $PROTOCOL"
67+
68+
# Zielordner: ohne DEPLOY_DIR erst visustruct.org, dann der Startordner des
69+
# Logins (FTP-Benutzer, die direkt in visustruct.org landen). Hochgeladen wird
70+
# nur in einen Ordner, in dem schon VisuStruct liegt (index.html nennt
71+
# VisuStruct oder ein früherer Lauf hat seine Dateiliste hinterlassen).
72+
looks_like_site() {
73+
lftp -c "$(connect_for "$PROTOCOL"); set cmd:fail-exit no; cd \"$1\" || exit 1; cat index.html" 2>/dev/null | grep -q VisuStruct \
74+
|| lftp -c "$(connect_for "$PROTOCOL"); cd \"$1\"; cls -1 $MANIFEST" >/dev/null 2>&1
75+
}
76+
if [ -z "$REMOTE_DIR" ]; then
77+
for d in visustruct.org .; do
78+
if looks_like_site "$d"; then REMOTE_DIR="$d"; break; fi
79+
done
80+
if [ -z "$REMOTE_DIR" ]; then
81+
echo "::error::Kein Zielordner gefunden: weder visustruct.org noch der Startordner des Logins enthalten die VisuStruct-Webseite. Bitte die Variable DEPLOY_DIR setzen."
82+
exit 1
83+
fi
84+
elif ! looks_like_site "$REMOTE_DIR"; then
85+
echo "::error::Im Zielordner '$REMOTE_DIR' liegt keine VisuStruct-Webseite (index.html), es wird nichts hochgeladen."
86+
exit 1
87+
fi
88+
echo "Zielordner: $REMOTE_DIR"
89+
connect="$(connect_for "$PROTOCOL")
4790
cd \"$REMOTE_DIR\""
4891

92+
# Fehlermeldungen von lftp zusätzlich als Annotation ausgeben (in der Übersicht
93+
# des Laufs sichtbar, ohne das Log zu öffnen)
94+
fail() {
95+
local msg
96+
msg="$(grep -v '^$' "$work/err" | tail -n 3 | tr '\n' ' ')"
97+
echo "::error::Upload fehlgeschlagen: ${msg:-unbekannter Fehler}"
98+
exit 1
99+
}
100+
49101
# Neue Dateiliste
50102
(cd "$SOURCE_DIR" && find . -type f ! -name .DS_Store ! -name "$MANIFEST" | sed 's|^\./||' | LC_ALL=C sort) > "$work/new"
51103

@@ -74,14 +126,14 @@ echo "Dateien: $(wc -l < "$work/new") hochladen, $(wc -l < "$work/rm.lftp") vera
74126
sed 's/^rm -f / löschen: /' "$work/rm.lftp"
75127

76128
if [ "$DRY_RUN" = "1" ]; then
77-
lftp -c "$connect; mirror -R --dry-run --no-perms --exclude-glob .DS_Store \"$SOURCE_DIR\" ."
129+
lftp -c "$connect; mirror -R --dry-run --no-perms --exclude-glob .DS_Store \"$SOURCE_DIR\" ." 2> >(tee "$work/err" >&2) || fail
78130
echo "Trockenlauf: nichts geändert."
79131
exit 0
80132
fi
81133

82134
# Erst alles außer HTML (Skripte, Bilder, CSS), dann die Seiten selbst,
83135
# damit keine Seite live ist, deren Assets noch fehlen.
84-
lftp <<LFTP
136+
lftp 2> >(tee "$work/err" >&2) <<LFTP || fail
85137
$connect
86138
mirror -R --no-perms --parallel=4 --exclude-glob .DS_Store --exclude-glob *.html "$SOURCE_DIR" .
87139
mirror -R --no-perms --parallel=4 --exclude-glob .DS_Store "$SOURCE_DIR" .

‎.github/workflows/deploy-website.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ jobs:
6868
- name: Hochladen
6969
env:
7070
DEPLOY_HOST: ${{ vars.DEPLOY_HOST || 'w0103087.kasserver.com' }}
71-
DEPLOY_PROTOCOL: ${{ vars.DEPLOY_PROTOCOL || 'sftp' }}
72-
DEPLOY_DIR: ${{ vars.DEPLOY_DIR || 'visustruct.org' }}
71+
DEPLOY_PROTOCOL: ${{ vars.DEPLOY_PROTOCOL || 'ftps' }}
72+
DEPLOY_DIR: ${{ vars.DEPLOY_DIR }}
7373
DEPLOY_USER: ${{ secrets.SFTP_USER }}
7474
LFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }}
7575
DRY_RUN: ${{ (inputs.dry_run || github.event_name == 'pull_request') && '1' || '0' }}

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ git clone https://github.com/code4teaching/VisuStruct-SwiftUI.git
2828

2929
## Website deployment
3030

31-
`website/` is published to visustruct.org (All-Inkl) by the workflow **Webseite veröffentlichen** (`.github/workflows/deploy-website.yml`). It runs the web tests first and then uploads via SFTP (`.github/scripts/deploy-website.sh`).
31+
`website/` is published to visustruct.org (All-Inkl) by the workflow **Webseite veröffentlichen** (`.github/workflows/deploy-website.yml`). It runs the web tests first and then uploads via FTPS, i.e. encrypted FTP (`.github/scripts/deploy-website.sh`).
3232

3333
- **Publish:** push a tag `web-v…` (e.g. `web-v1.0`, also possible via *Releases → Draft a new release*), or start it by hand under *Actions → Webseite veröffentlichen → Run workflow* (with an optional dry run).
3434
- **Secrets** (*Settings → Secrets and variables → Actions*): `SFTP_USER`, `SFTP_PASSWORD`.
35-
- **Optional variables:** `DEPLOY_HOST` (default `w0103087.kasserver.com`), `DEPLOY_DIR` (default `visustruct.org`), `DEPLOY_PROTOCOL` (`sftp` or `ftps`).
35+
- **Optional variables:** `DEPLOY_HOST` (default `w0103087.kasserver.com`), `DEPLOY_DIR` (default: `visustruct.org` or the login's start folder, whichever holds the VisuStruct site), `DEPLOY_PROTOCOL` (default `ftps`; `sftp` or `auto` = try SFTP, then FTPS).
3636
- On the server only files from earlier deployments (listed in `.visustruct-deploy-manifest.txt`) and outdated build files in `app/assets/` are deleted. Other files are left alone.
3737

3838
## Changelog / release notes

0 commit comments

Comments
 (0)