Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .github/scripts/deploy-website.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env bash
# Lädt den Ordner website/ per SFTP (oder FTPS) zu All-Inkl hoch.
#
# Auf dem Server wird nur gelöscht, was ein früherer Lauf dieses Skripts selbst
# hochgeladen hat (Liste in .visustruct-deploy-manifest.txt im Zielordner), und
# veraltete Build-Dateien in app/assets/.
# Fremde Dateien im Zielordner und alles außerhalb davon bleiben unangetastet.
#
# Umgebung:
# DEPLOY_HOST, DEPLOY_USER, LFTP_PASSWORD Pflicht
# DEPLOY_PROTOCOL sftp (Standard) oder ftps
# DEPLOY_DIR Zielordner relativ zum Login, Standard visustruct.org
# ("." wenn der FTP-Benutzer direkt in diesem Ordner landet)
# SOURCE_DIR Standard website
# DRY_RUN=1 nur anzeigen, nichts hochladen oder löschen
set -euo pipefail

: "${DEPLOY_HOST:?DEPLOY_HOST fehlt}"
: "${DEPLOY_USER:?DEPLOY_USER fehlt}"
: "${LFTP_PASSWORD:?LFTP_PASSWORD fehlt}"
export LFTP_PASSWORD

PROTOCOL="${DEPLOY_PROTOCOL:-sftp}"
REMOTE_DIR="${DEPLOY_DIR:-visustruct.org}"
SOURCE_DIR="${SOURCE_DIR:-website}"
DRY_RUN="${DRY_RUN:-0}"
MANIFEST=".visustruct-deploy-manifest.txt"

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

case "$PROTOCOL" in
sftp) URL="sftp://$DEPLOY_HOST"
SETTINGS="set sftp:auto-confirm yes" ;;
ftps) URL="ftp://$DEPLOY_HOST"
SETTINGS="set ftp:ssl-force true; set ftp:ssl-protect-data true; set ssl:verify-certificate ${DEPLOY_VERIFY_CERT:-yes}" ;;
*) echo "DEPLOY_PROTOCOL muss sftp oder ftps sein" >&2; exit 1 ;;
esac

work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT

connect="$SETTINGS; set net:max-retries 3; set net:timeout 30; set cmd:fail-exit yes
open --env-password -u \"$DEPLOY_USER\" $URL
cd \"$REMOTE_DIR\""

# Neue Dateiliste
(cd "$SOURCE_DIR" && find . -type f ! -name .DS_Store ! -name "$MANIFEST" | sed 's|^\./||' | LC_ALL=C sort) > "$work/new"

# Alte Dateiliste vom Server (fehlt beim ersten Lauf)
if ! lftp -c "$connect; get $MANIFEST -o \"$work/old\"" 2>/dev/null; then
echo "Keine frühere Dateiliste auf dem Server gefunden, es wird nichts gelöscht."
: > "$work/old"
fi

# app/assets/ wird von Vite bei jedem Build komplett neu erzeugt (Dateinamen mit
# Hash). Was dort auf dem Server liegt und nicht mehr zum Build gehört, ist veraltet,
# auch wenn es noch von Hand hochgeladen wurde.
lftp -c "$connect; cls -1 app/assets/" 2>/dev/null | sed 's|^.*/||; s|^|app/assets/|' | grep -v '/$' >> "$work/old" || true

# Dateien, die früher hochgeladen wurden und jetzt nicht mehr dazugehören
LC_ALL=C sort -u "$work/old" | LC_ALL=C comm -23 - "$work/new" > "$work/stale"
: > "$work/rm.lftp"
while IFS= read -r f; do
case "$f" in
""|/*|*..*|*'"'*|*'\'*) echo "Überspringe verdächtigen Eintrag: '$f'" >&2; continue ;;
esac
echo "rm -f \"$f\"" >> "$work/rm.lftp"
done < "$work/stale"

echo "Dateien: $(wc -l < "$work/new") hochladen, $(wc -l < "$work/rm.lftp") veraltete löschen (Ziel: $REMOTE_DIR)"
sed 's/^rm -f / löschen: /' "$work/rm.lftp"

if [ "$DRY_RUN" = "1" ]; then
lftp -c "$connect; mirror -R --dry-run --no-perms --exclude-glob .DS_Store \"$SOURCE_DIR\" ."
echo "Trockenlauf: nichts geändert."
exit 0
fi

# Erst alles außer HTML (Skripte, Bilder, CSS), dann die Seiten selbst,
# damit keine Seite live ist, deren Assets noch fehlen.
lftp <<LFTP
$connect
mirror -R --no-perms --parallel=4 --exclude-glob .DS_Store --exclude-glob *.html "$SOURCE_DIR" .
mirror -R --no-perms --parallel=4 --exclude-glob .DS_Store "$SOURCE_DIR" .
source "$work/rm.lftp"
put "$work/new" -o $MANIFEST
LFTP
echo "Fertig."
76 changes: 76 additions & 0 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Webseite veröffentlichen

# Lädt website/ nach All-Inkl (visustruct.org) hoch.
# Start: Tag web-v… anlegen (z. B. web-v1.0, auch über „Draft a new release“)
# oder von Hand unter Actions → „Webseite veröffentlichen“ → „Run workflow“.
# Ändert ein PR den Upload selbst, läuft nur ein Trockenlauf gegen den Server.
on:
pull_request:
paths:
- '.github/workflows/deploy-website.yml'
- '.github/scripts/deploy-website.sh'
push:
tags: ['web-v*']
workflow_dispatch:
inputs:
dry_run:
description: 'Trockenlauf: nur anzeigen, was hochgeladen und gelöscht würde'
type: boolean
default: false

permissions:
contents: read

concurrency:
group: deploy-website
cancel-in-progress: false

jobs:
check:
runs-on: ubuntu-latest
defaults:
run:
working-directory: web
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: web/package-lock.json
- run: npm ci
- name: Test
run: npm test
- name: website/app ist aktuell
run: |
npm run build:site
git diff --exit-code -- ../website/app || (echo "website/app ist veraltet: in web/ 'npm run build:site' ausführen und committen." && exit 1)
test -z "$(git status --porcelain -- ../website/app)"
deploy:
needs: check
# PRs aus Forks bekommen keine Secrets
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Zugangsdaten vorhanden?
env:
SFTP_USER: ${{ secrets.SFTP_USER }}
SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }}
run: |
if [ -z "$SFTP_USER" ] || [ -z "$SFTP_PASSWORD" ]; then
echo "::error::Die Secrets SFTP_USER und SFTP_PASSWORD fehlen (Settings → Secrets and variables → Actions)."
exit 1
fi
- name: lftp installieren
run: sudo apt-get update -q && sudo apt-get install -y -q lftp
- name: Hochladen
env:
DEPLOY_HOST: ${{ vars.DEPLOY_HOST || 'w0103087.kasserver.com' }}
DEPLOY_PROTOCOL: ${{ vars.DEPLOY_PROTOCOL || 'sftp' }}
DEPLOY_DIR: ${{ vars.DEPLOY_DIR || 'visustruct.org' }}
DEPLOY_USER: ${{ secrets.SFTP_USER }}
LFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }}
DRY_RUN: ${{ (inputs.dry_run || github.event_name == 'pull_request') && '1' || '0' }}
run: .github/scripts/deploy-website.sh
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is loosely inspired by Keep a Changelog.

## [Unreleased]

### Added

- **Website:** GitHub Actions workflow that publishes `website/` to visustruct.org via SFTP after the web tests pass (tag `web-v…` or manual start).

### Changed

- **App:** the area below the diagram is headed “Object Inspector · <element kind>” (German „Objektinspektor · Verzweigung“ etc.), matching the web editor and the lessons. The palette keeps its heading “Elements”.
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ git clone https://github.com/code4teaching/VisuStruct-SwiftUI.git

**Remote:** [github.com/code4teaching/VisuStruct-SwiftUI](https://github.com/code4teaching/VisuStruct-SwiftUI)

## Website deployment

`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`).

- **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).
- **Secrets** (*Settings → Secrets and variables → Actions*): `SFTP_USER`, `SFTP_PASSWORD`.
- **Optional variables:** `DEPLOY_HOST` (default `w0103087.kasserver.com`), `DEPLOY_DIR` (default `visustruct.org`), `DEPLOY_PROTOCOL` (`sftp` or `ftps`).
- 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.

## Changelog / release notes

Versioned release notes live in **[CHANGELOG.md](CHANGELOG.md)**. On the repository’s **GitHub home page**, only this **README** is shown in full by default; open `CHANGELOG.md` in the file list (or use the **Changes** link at the top) to read the history. The **Releases** tab only shows extra notes if you create [GitHub Releases](https://github.com/code4teaching/VisuStruct-SwiftUI/releases) (optional, in addition to the changelog file).
Loading