name: Build & Deploy (Nix) on: push: branches: - main jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v4 - name: Deploy via SSH (build + deploy on VPS) env: VPS_HOST: ${{ secrets.VPS_HOST }} VPS_USER: ${{ secrets.VPS_USER }} VPS_SSH_KEY_VALUE: ${{ secrets.VPS_SSH_KEY_VALUE }} run: | set -eu key_file=$(mktemp) printf '%s\n' "$VPS_SSH_KEY_VALUE" > "$key_file" chmod 600 "$key_file" ssh -i "$key_file" -o StrictHostKeyChecking=no \ "${VPS_USER}@${VPS_HOST}" " export PATH=\"\$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:\$PATH\" REPO_DIR=\"/home/teleuploader/repo\" if [ -d \"\$REPO_DIR/.git\" ]; then cd \"\$REPO_DIR\" && git pull origin main 2>&1 else mkdir -p \"\$REPO_DIR\" git clone https://git.imrnes.team/MythEclipse/TeleUploader \"\$REPO_DIR\" 2>&1 cd \"\$REPO_DIR\" fi cd \"\$REPO_DIR\" nix build .#teleuploader --impure --option sandbox false 2>&1 STORE_PATH=\$(readlink result) nix-env --profile /nix/var/nix/profiles/teleuploader --set \"\$STORE_PATH\" systemctl restart teleuploader sleep 3 systemctl status teleuploader --no-pager 2>&1 | head -15 "