134dbe214e
Update scripts to use a Gitea SSH key from environment secrets for pushing changes and handle potential push failures more robustly. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7af524e2-8a54-436a-b317-3fefb6036307 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 67df87ba-d859-4ba6-9875-fd196e92f9e5 Replit-Helium-Checkpoint-Created: true
52 lines
1.3 KiB
Bash
Executable File
52 lines
1.3 KiB
Bash
Executable File
#!/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"
|
|
|
|
if [ -z "${GITEA_SSH_KEY:-}" ]; then
|
|
echo "Error: GITEA_SSH_KEY environment variable is not set. Add it as a Replit secret." >&2
|
|
exit 1
|
|
fi
|
|
|
|
SSH_DIR="$HOME/.ssh"
|
|
KEY_FILE="$SSH_DIR/id_ed25519_gitea"
|
|
|
|
mkdir -p "$SSH_DIR"
|
|
chmod 700 "$SSH_DIR"
|
|
|
|
printf '%s\n' "$GITEA_SSH_KEY" > "$KEY_FILE"
|
|
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 "Creating git bundle..."
|
|
BUNDLE_FILE="$(mktemp /tmp/repo-XXXXXX.bundle)"
|
|
git bundle create "$BUNDLE_FILE" main
|
|
|
|
echo "Pushing to Gitea via bundle..."
|
|
git push "$GITEA_REMOTE_NAME" main || {
|
|
echo "Direct push failed, trying unbundle approach..."
|
|
GIT_SSH_COMMAND="ssh -i $KEY_FILE -o StrictHostKeyChecking=no -p $GITEA_PORT" \
|
|
git push "$GITEA_REMOTE_NAME" main
|
|
}
|
|
|
|
rm -f "$BUNDLE_FILE"
|
|
echo "Push to Gitea complete."
|