Files
flights_web/.gitea/workflows/ci-deploy.yml
T
gnezim 9687183e91 ci: switch runner label to ubuntu-latest + e2e via public URL
Runner advertises ubuntu-latest/24.04/22.04 (not pve-201). Jobs now run
inside docker.gitea.com/runner-images:ubuntu-latest containers.

E2e BASE_URL switches from http://127.0.0.1:3002 (host loopback, not
reachable from runner container) to https://ui-dashboard.gnerim.ru with
basic-auth httpCredentials. Tests now traverse the full nginx + auth +
container path, which is what we want anyway.
2026-04-27 13:47:23 +03:00

133 lines
3.8 KiB
YAML

name: ci-deploy
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build-deploy-test:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
MAP_TILE_URL: ${{ secrets.MAP_TILE_URL || '/map/api/tile/{z}/{x}/{y}.jpeg' }}
API_BASE_URL: ${{ secrets.API_BASE_URL || '/api' }}
BASIC_AUTH_USER: ${{ secrets.BASIC_AUTH_USER }}
BASIC_AUTH_PASS: ${{ secrets.BASIC_AUTH_PASS }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
FLIGHTS_WEB_PORT: '3002'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Notify start
if: ${{ env.TELEGRAM_BOT_TOKEN != '' }}
run: scripts/ci/notify-telegram.sh start ci-deploy
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Restore pnpm cache
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-
- name: Install dependencies
id: deps
run: pnpm install --frozen-lockfile
- name: Typecheck
id: typecheck
run: pnpm typecheck
- name: Lint
id: lint
run: pnpm lint
- name: Unit tests
id: unit
run: pnpm test
- name: CI script tests
id: citest
run: pnpm test:ci
- name: Build SSR image
id: docker_build
run: |
docker build -f Dockerfile.react \
--build-arg "MAP_TILE_URL=${MAP_TILE_URL}" \
--build-arg "API_BASE_URL=${API_BASE_URL}" \
-t "flights-web:${GITHUB_SHA:0:7}" \
.
- name: Swap container
id: swap
run: scripts/ci/deploy-container.sh swap
- name: Wait for health
id: health
env:
BASIC_AUTH_USER: ${{ secrets.BASIC_AUTH_USER }}
BASIC_AUTH_PASS: ${{ secrets.BASIC_AUTH_PASS }}
run: scripts/ci/wait-for-url.sh https://ui-dashboard.gnerim.ru/ 30 2
- name: Install Playwright browsers
id: playwright_install
run: pnpm exec playwright install chromium
- name: Run Playwright e2e
id: e2e
env:
BASE_URL: https://ui-dashboard.gnerim.ru
BASIC_AUTH_USER: ${{ secrets.BASIC_AUTH_USER }}
BASIC_AUTH_PASS: ${{ secrets.BASIC_AUTH_PASS }}
run: pnpm test:e2e
- name: Rollback on failure (post-deploy steps)
if: failure() && (steps.swap.outcome == 'failure' || steps.health.outcome == 'failure' || steps.e2e.outcome == 'failure')
id: rollback
run: scripts/ci/deploy-container.sh rollback
- name: Capture container logs (on failure)
if: failure()
run: docker logs flights-web --tail 500 > container.log 2>&1 || true
- name: Upload artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: ci-deploy-failure-${{ github.run_id }}
path: |
container.log
playwright-report/
retention-days: 7
- name: Prune old images
if: success()
run: |
docker images flights-web --format '{{.Tag}} {{.ID}}' \
| grep -vE '^(current|previous)\b' \
| tail -n +6 \
| awk '{print $2}' \
| xargs -r docker rmi 2>/dev/null || true
- name: Notify (success)
if: success() && env.TELEGRAM_BOT_TOKEN != ''
run: scripts/ci/notify-telegram.sh ok ci-deploy
- name: Notify (failure)
if: failure() && env.TELEGRAM_BOT_TOKEN != ''
run: scripts/ci/notify-telegram.sh fail ci-deploy "see run for details" container.log