Commit fe37e632 authored by Aryan Noshirvani's avatar Aryan Noshirvani

Simplify deployment: use mounted SSH key from runner

parent 9168dc93
......@@ -28,21 +28,8 @@ deploy_prod:
image: python:3.10-slim
before_script:
- apt-get update && apt-get install -y --no-install-recommends openssh-client bash
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null\n" > ~/.ssh/config
script:
- echo "Deploying to Iran production server..."
- |
if [ -n "$SSH_PRIVATE_KEY" ]; then
if [ -f "$SSH_PRIVATE_KEY" ]; then
cp "$SSH_PRIVATE_KEY" ~/.ssh/id_ed25519
else
printf "%s\n" "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_ed25519
fi
chmod 600 ~/.ssh/id_ed25519
else
echo "WARNING: SSH_PRIVATE_KEY variable is not set."
fi
- ssh -i ~/.ssh/id_ed25519 -p ${PROD_SSH_PORT:-2222} root@${PROD_SERVER_IP:-127.0.0.1} "cd /root/stax_backend_api && GIT_SSL_NO_VERIFY=true git pull origin main && source venv/bin/activate && pip install --prefer-binary -r requirements.txt && systemctl restart stax_backend"
- ssh -o StrictHostKeyChecking=no -i /root/.ssh/id_ed25519 -p ${PROD_SSH_PORT:-2222} root@${PROD_SERVER_IP:-127.0.0.1} "cd /root/stax_backend_api && GIT_SSL_NO_VERIFY=true git pull origin main && source venv/bin/activate && pip install --prefer-binary -r requirements.txt && systemctl restart stax_backend"
only:
- main
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment