56 lines
1.8 KiB
YAML
56 lines
1.8 KiB
YAML
name: CD
|
|
|
|
# Every merge into dev → lint + tests → deploy to the shared server (dev.meditron.tenvex.ru / meditron.tenvex.ru).
|
|
# Secrets: DEPLOY_SSH_KEY (private key of the `ptsr-deploy` user), DEPLOY_HOST (user@host).
|
|
on:
|
|
push:
|
|
branches: [dev]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: deploy-dev
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
test:
|
|
name: ruff · pytest
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: astral-sh/setup-uv@v3
|
|
with:
|
|
version: "0.8.4"
|
|
- run: uv sync --frozen
|
|
- run: uv run ruff check .
|
|
- run: uv run pytest -q
|
|
|
|
deploy:
|
|
name: deploy dev
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: ssh key
|
|
run: |
|
|
install -d -m 700 ~/.ssh
|
|
printf '%s\n' "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
|
|
chmod 600 ~/.ssh/deploy_key
|
|
printf '%s\n' "${{ secrets.SERVICE_ENV }}" > ~/service.env
|
|
chmod 600 ~/service.env
|
|
- name: deploy
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
DEPLOY_SSH_OPTS: "-i /root/.ssh/deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=20"
|
|
run: |
|
|
export DEPLOY_SSH_OPTS="${DEPLOY_SSH_OPTS//\/root\/.ssh/$HOME/.ssh}"
|
|
export SERVICE_ENV_FILE="$HOME/service.env"
|
|
infra/deploy/deploy.sh HEAD
|
|
- name: smoke
|
|
run: |
|
|
sleep 10
|
|
for u in https://dev.meditron.tenvex.ru/ https://dev.meditron.tenvex.ru/api/v1/demo/personas https://dev.meditron.tenvex.ru/doctor/; do
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' -m 20 "$u"); echo "$u -> $code"; [ "$code" = 200 ]
|
|
done
|