Add portal styleguide sync flow
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
# Portal Sync Flow
|
||||||
|
|
||||||
|
## Ziel
|
||||||
|
|
||||||
|
Der Styleguide bleibt in diesem Repository die Source of Truth. Das Portal holt den Stand versioniert als `public/assets/styleguide.upstream.css`.
|
||||||
|
|
||||||
|
## Vorbereitung
|
||||||
|
|
||||||
|
- Version in `VERSION` erhoehen, sobald ein freigegebener Stand vorliegt.
|
||||||
|
- Aenderungen im Styleguide committen und pushen.
|
||||||
|
|
||||||
|
## Sync ausfuehren
|
||||||
|
|
||||||
|
Beispiel:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/sync_styleguide_to_portal.sh \
|
||||||
|
--portal-repo "/Users/mathias/Documents/Dokumente Chouchou/Codebases/WebApp_Aktienberater" \
|
||||||
|
--commit-portal
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ergebnis im Portalrepo
|
||||||
|
|
||||||
|
- `public/assets/styleguide.upstream.css` aktualisiert
|
||||||
|
- `public/assets/styleguide.upstream.meta.json` aktualisiert (Version, Commit, Zeitstempel)
|
||||||
|
- Optional: automatischer Commit + Push im Portalrepo
|
||||||
|
|
||||||
|
## Standardprozess je Release
|
||||||
|
|
||||||
|
1. Styleguide aendern
|
||||||
|
2. `VERSION` erhoehen
|
||||||
|
3. Styleguide commit + push
|
||||||
|
4. Sync-Skript ausfuehren
|
||||||
|
5. Portal Smoke-Test
|
||||||
Executable
+103
@@ -0,0 +1,103 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
STYLEGUIDE_REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
|
SOURCE_CSS="$STYLEGUIDE_REPO_ROOT/styleguide.css"
|
||||||
|
VERSION_FILE="$STYLEGUIDE_REPO_ROOT/VERSION"
|
||||||
|
|
||||||
|
PORTAL_REPO_PATH=""
|
||||||
|
PORTAL_CSS_REL="public/assets/styleguide.upstream.css"
|
||||||
|
PORTAL_META_REL="public/assets/styleguide.upstream.meta.json"
|
||||||
|
COMMIT_IN_PORTAL="false"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<USAGE
|
||||||
|
Usage:
|
||||||
|
$(basename "$0") --portal-repo <path> [--commit-portal]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--portal-repo <path> Absolute path to portal repository root.
|
||||||
|
--commit-portal Create commit in portal repo after sync.
|
||||||
|
-h, --help Show this help.
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--portal-repo)
|
||||||
|
PORTAL_REPO_PATH="${2:-}"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--commit-portal)
|
||||||
|
COMMIT_IN_PORTAL="true"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown argument: $1" >&2
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z "$PORTAL_REPO_PATH" ]]; then
|
||||||
|
echo "Missing required argument: --portal-repo" >&2
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$SOURCE_CSS" ]]; then
|
||||||
|
echo "Source CSS not found: $SOURCE_CSS" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$VERSION_FILE" ]]; then
|
||||||
|
echo "Version file not found: $VERSION_FILE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$PORTAL_REPO_PATH/.git" ]]; then
|
||||||
|
echo "Portal repo is not a git repository: $PORTAL_REPO_PATH" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PORTAL_CSS_PATH="$PORTAL_REPO_PATH/$PORTAL_CSS_REL"
|
||||||
|
PORTAL_META_PATH="$PORTAL_REPO_PATH/$PORTAL_META_REL"
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$PORTAL_CSS_PATH")"
|
||||||
|
|
||||||
|
cp "$SOURCE_CSS" "$PORTAL_CSS_PATH"
|
||||||
|
|
||||||
|
STYLEGUIDE_VERSION="$(tr -d '[:space:]' < "$VERSION_FILE")"
|
||||||
|
STYLEGUIDE_COMMIT="$(git -C "$STYLEGUIDE_REPO_ROOT" rev-parse --short HEAD)"
|
||||||
|
SYNCED_AT="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
||||||
|
|
||||||
|
cat > "$PORTAL_META_PATH" <<META
|
||||||
|
{
|
||||||
|
"styleguideVersion": "$STYLEGUIDE_VERSION",
|
||||||
|
"styleguideCommit": "$STYLEGUIDE_COMMIT",
|
||||||
|
"syncedAtUtc": "$SYNCED_AT",
|
||||||
|
"sourceRepo": "$STYLEGUIDE_REPO_ROOT"
|
||||||
|
}
|
||||||
|
META
|
||||||
|
|
||||||
|
if [[ "$COMMIT_IN_PORTAL" == "true" ]]; then
|
||||||
|
git -C "$PORTAL_REPO_PATH" add "$PORTAL_CSS_REL" "$PORTAL_META_REL"
|
||||||
|
if ! git -C "$PORTAL_REPO_PATH" diff --cached --quiet; then
|
||||||
|
git -C "$PORTAL_REPO_PATH" commit -m "Sync styleguide $STYLEGUIDE_VERSION"
|
||||||
|
git -C "$PORTAL_REPO_PATH" push
|
||||||
|
echo "Portal repo synced and pushed."
|
||||||
|
else
|
||||||
|
echo "No changes to commit in portal repo."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Portal files updated locally (no commit requested)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Synced $SOURCE_CSS -> $PORTAL_CSS_PATH"
|
||||||
|
echo "Metadata written: $PORTAL_META_PATH"
|
||||||
Reference in New Issue
Block a user