Skip to content

feat(winrate): add MQ gate, confirmation store, exit safety and tests #12

feat(winrate): add MQ gate, confirmation store, exit safety and tests

feat(winrate): add MQ gate, confirmation store, exit safety and tests #12

name: Deploy on Merge (optional)

Check failure on line 1 in .github/workflows/deploy-on-merge.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy-on-merge.yml

Invalid workflow file

(Line: 48, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.DEPLOY_HOST != '' && secrets.DEPLOY_SSH_KEY != '', (Line: 55, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.DEPLOY_HOST != '' && secrets.DEPLOY_SSH_KEY != '', (Line: 60, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.DEPLOY_HOST != '' && secrets.DEPLOY_SSH_KEY != ''
# This workflow performs an optional SSH/SCP deploy when code is merged to `main`.
# It only runs the deploy step if the required secrets are provided in the repository:
# - DEPLOY_HOST
# - DEPLOY_USER
# - DEPLOY_SSH_KEY
# - DEPLOY_TARGET
#
# To enable: add the above secrets in GitHub → Settings → Secrets → Actions.
on:
push:
branches:
- main
jobs:
build:
name: Build / Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install deps (if any)
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run quick tests (if pytest)
run: |
if command -v pytest >/dev/null 2>&1; then pytest -q || true; fi
deploy:
name: Deploy (conditional)
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare SSH key
if: ${{ secrets.DEPLOY_HOST != '' && secrets.DEPLOY_SSH_KEY != '' }}
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Ensure known_hosts (optional)
if: ${{ secrets.DEPLOY_HOST != '' && secrets.DEPLOY_SSH_KEY != '' }}
run: |
ssh-keyscan -p "${{ secrets.DEPLOY_PORT }}" -H "${{ secrets.DEPLOY_HOST }}" >> ~/.ssh/known_hosts || true
- name: Copy files to target via scp
if: ${{ secrets.DEPLOY_HOST != '' && secrets.DEPLOY_SSH_KEY != '' }}
run: |
TARGET="${{ secrets.DEPLOY_TARGET }}"
HOST="${{ secrets.DEPLOY_HOST }}"
USER="${{ secrets.DEPLOY_USER }}"
PORT="${{ secrets.DEPLOY_PORT }}"
if [ -z "$PORT" ]; then PORT=22; fi
echo "Deploying to $USER@$HOST:$TARGET (port $PORT) using rsync with .deployignore"
# Prefer using .deployignore in repo root to control excludes.
if [ -f .deployignore ]; then
rsync -az --delete --exclude-from='.deployignore' -e "ssh -p $PORT -o StrictHostKeyChecking=yes" . "$USER@$HOST:$TARGET"
else
echo ".deployignore not found, using conservative inline excludes"
rsync -az --delete \
--exclude='.git' \
--exclude='.env' \
--exclude='*.env' \
--exclude='venv/' \
--exclude='.venv/' \
--exclude='env/' \
--exclude='__pycache__/' \
--exclude='*.pyc' \
--exclude='local_markets_db/' \
--exclude='*.sqlite' \
--exclude='*.db' \
--exclude='logs/' \
-e "ssh -p $PORT -o StrictHostKeyChecking=yes" . "$USER@$HOST:$TARGET"
fi