Files
marco/scripts/sync-kosmos.sh
T
raucao 4a8080a41a
CI / Test (push) Canceled after 0s
CI / Lint (push) Canceled after 1m8s
Make sync-kosmos.sh complete
2026-12-01 10:56:43 +04:00

57 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
#
# Sync the `kosmos` deployment branch from `master`, rebuild its release, push
# it to both Gitea and 5apps, and return to `master`.
#
# Marco is deployed to two domains from two branches, both serving the committed
# `release/` directory via 5apps Deploy:
#
# master -> https://marco.earth (git push 5apps master)
# kosmos -> https://marco.kosmos.org (git push 5apps-old kosmos:master)
#
# The only intentional source difference between the branches is
# `.env.production` (app origin + OSM OAuth client ID). `release/` is a build
# artifact committed to each branch, so it must be regenerated for the kosmos
# domain after every merge from master.
#
# Usage: ./scripts/sync-kosmos.sh
#
set -e
if [ -n "$(git status --porcelain)" ]; then
echo "Working tree is not clean. Commit or stash your changes first." >&2
exit 1
fi
git checkout kosmos
git merge --no-commit --no-ff master || true
# Any conflict outside of the two expected paths is unexpected and should be
# resolved by hand.
conflicts=$(git diff --name-only --diff-filter=U | grep -vE '^(release/|\.env\.production$)' || true)
if [ -n "$conflicts" ]; then
echo "Unresolved conflicts outside release/ and .env.production:" >&2
echo "$conflicts" >&2
exit 1
fi
# Keep the kosmos domain config instead of the one coming from master.
git checkout HEAD -- .env.production
# Rebuild the release from scratch for the kosmos domain.
rm -rf release
pnpm build
git add -A release .env.production
if [ -f "$(git rev-parse --git-path MERGE_HEAD)" ]; then
git commit --no-edit
elif ! git diff --cached --quiet; then
git commit -m "Sync kosmos release"
else
echo "Already up to date."
fi
git push origin kosmos
git push 5apps-old kosmos:master
git checkout master