Files
Train-ID/.gitea/workflows/deploy.yaml
Hudson Riggs d8f3edb9fe
Some checks failed
Deploy to Server / deploy (push) Failing after 4s
Workflows ETC
2025-10-25 18:03:36 -04:00

42 lines
1.2 KiB
YAML

name: Deploy to Server
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install SSH Key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan 192.168.30.114 >> ~/.ssh/known_hosts
- name: Deploy via SSH
run: |
ssh deployuser@192.168.30.114 << 'EOF'
set -euo pipefail
APP_DIR=/opt/Train-ID
SERVICE=train-id
if [ ! -d "$APP_DIR" ]; then
sudo mkdir -p "$APP_DIR"
sudo chown "$USER":"$USER" "$APP_DIR"
git clone https://git.hudsonriggs.systems/HRiggs/Train-ID.git "$APP_DIR"
fi
cd "$APP_DIR"
git pull origin main
# Install Node.js deps and build
npm ci || npm install
npm run build
# Ensure systemd service exists and restart
if systemctl list-unit-files | grep -q "${SERVICE}.service"; then
sudo systemctl restart "$SERVICE"
else
echo "Warning: ${SERVICE}.service not found; start your process manager manually."
fi
EOF