ci: отдельная база для каждого стенда

deploy-staging создаёт роль и БД ветки через staging-db-postgres до
docker compose up, cleanup.yaml удаляет их при удалении ветки (гасит
стек раньше, иначе DROP DATABASE не пройдёт). POSTGRES_* в compose
читаются из .env, куда инструмент пишет доступы.

Попутно: DEPLOY_URL стенда из env и в summary, версия сборки — ветка и
короткий sha, в проде APP_VERSION берётся из VERSION, health в Caddyfile
одной строкой.
This commit is contained in:
arswarog committed 2026-10-29 14:59:51 +03:00
1 parent fc13c66b0d
commit ae812b0dfa
6 files changed
+63 -43

No files matched your search

+14 -3
View File
@@ -44,8 +44,16 @@ jobs:
- name: Check migrations list
run: yarn ts-node tools/buildDataSource.ts --check
- name: Compute version
id: version
env:
REF_NAME: ${{ github.head_ref || github.ref_name }}
run: echo "VERSION=$REF_NAME-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: Build
run: yarn build
env:
APP_VERSION: ${{ steps.version.outputs.VERSION }}
- name: Check data-source
run: yarn ts-node tools/checkDataSource.ts
@@ -79,6 +87,8 @@ jobs:
name: Деплой на стейджинг
runs-on: ubuntu-latest
needs: build
env:
DEPLOY_URL: https://${{ github.head_ref || github.ref_name }}.jt4d.jt4d.ru.net
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -113,6 +123,7 @@ jobs:
# $BRANCH — имя ветки из окружения.
sed -i "s/\${BRANCH}/$BRANCH/g" docker-compose.yml
docker compose pull --quiet
staging-db-postgres create "${{ github.repository }}" "$BRANCH"
docker compose down
docker compose up -d
@@ -121,14 +132,11 @@ jobs:
# echo "Применение миграций"
# docker compose exec -T api node_modules/.bin/typeorm migration:run -t each -d data-source.js
# Если migration:run упадёт, prune под `set -e` не выполнится —
# почистится на следующем деплое.
docker system prune -f
- name: Set deployment status
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
DEPLOY_URL: http://${{ github.head_ref || github.ref_name }}.geo-platform.geo-helm.jt4d.ru.net
run: |
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
@@ -141,6 +149,9 @@ jobs:
}' \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}"
- name: Write stand URL to summary
run: echo "**Стенд:** $DEPLOY_URL" >> "$GITHUB_STEP_SUMMARY"
check:
name: Проверка кода
runs-on: ubuntu-latest