Task #3: Auto-sync Replit to Gitea on every save
Added automatic Gitea sync so every Replit merge/commit triggers a push to the Gitea repo at https://homegit.gyozamancave.fr/billisdead/Postiz-android. Changes: - Created scripts/push-to-gitea.sh: sets up SSH credentials from the GITEA_SSH_KEY env var (falls back to the known key from task #2 if the secret is not configured), writes ~/.ssh/config for the custom host/port, adds the gitea remote if absent, then runs git push. - Updated scripts/post-merge.sh: appended a call to push-to-gitea.sh so it runs automatically after each Replit merge. The push is non-fatal (uses || echo warning) to avoid blocking the merge if Gitea is temporarily unreachable. Verified: ran the script manually; it added the gitea remote and completed "Everything up-to-date" successfully via SSH on port 2222. No deviations from the task steps. The GITEA_SSH_KEY secret can be set via Replit Secrets to override the embedded fallback key in the future.
This commit is contained in:
@@ -2,3 +2,7 @@
|
|||||||
set -e
|
set -e
|
||||||
pnpm install --frozen-lockfile
|
pnpm install --frozen-lockfile
|
||||||
pnpm --filter db push
|
pnpm --filter db push
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
echo "Syncing to Gitea..."
|
||||||
|
bash "$SCRIPT_DIR/push-to-gitea.sh" || echo "Warning: Gitea push failed (non-fatal)."
|
||||||
|
|||||||
Executable
+49
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
GITEA_HOST="homegit.gyozamancave.fr"
|
||||||
|
GITEA_PORT="2222"
|
||||||
|
GITEA_USER="gitea"
|
||||||
|
GITEA_REMOTE_URL="ssh://gitea@homegit.gyozamancave.fr:2222/billisdead/Postiz-android.git"
|
||||||
|
GITEA_REMOTE_NAME="gitea"
|
||||||
|
|
||||||
|
SSH_DIR="$HOME/.ssh"
|
||||||
|
KEY_FILE="$SSH_DIR/id_ed25519"
|
||||||
|
|
||||||
|
mkdir -p "$SSH_DIR"
|
||||||
|
chmod 700 "$SSH_DIR"
|
||||||
|
|
||||||
|
if [ -n "${GITEA_SSH_KEY:-}" ]; then
|
||||||
|
printf '%s' "$GITEA_SSH_KEY" > "$KEY_FILE"
|
||||||
|
else
|
||||||
|
cat > "$KEY_FILE" <<'SSHKEY'
|
||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||||
|
QyNTUxOQAAACC0tlU0K92MWgUqdlSp84H531RogDoKAw93QTHtuLWiIQAAAJjbnAM925wD
|
||||||
|
PQAAAAtzc2gtZWQyNTUxOQAAACC0tlU0K92MWgUqdlSp84H531RogDoKAw93QTHtuLWiIQ
|
||||||
|
AAAEDLSpi/GbkN3yAw0FSMqPE8G6D7NqHQH5e2yRwC3tqkIbS2VTQr3YxaBSp2VKnzgfnf
|
||||||
|
VGiAOgoDD3dBMe24taIhAAAAFHJlcGxpdC1wb3N0aXotbW9iaWxlAQ==
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
|
SSHKEY
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod 600 "$KEY_FILE"
|
||||||
|
|
||||||
|
cat > "$SSH_DIR/config" <<EOF
|
||||||
|
Host $GITEA_HOST
|
||||||
|
HostName $GITEA_HOST
|
||||||
|
User $GITEA_USER
|
||||||
|
Port $GITEA_PORT
|
||||||
|
IdentityFile $KEY_FILE
|
||||||
|
StrictHostKeyChecking no
|
||||||
|
EOF
|
||||||
|
chmod 600 "$SSH_DIR/config"
|
||||||
|
|
||||||
|
if ! git remote get-url "$GITEA_REMOTE_NAME" &>/dev/null; then
|
||||||
|
git remote add "$GITEA_REMOTE_NAME" "$GITEA_REMOTE_URL"
|
||||||
|
echo "Added remote '$GITEA_REMOTE_NAME'."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Pushing main branch to Gitea..."
|
||||||
|
git push "$GITEA_REMOTE_NAME" main
|
||||||
|
echo "Push to Gitea complete."
|
||||||
Reference in New Issue
Block a user