b2cd4b53fc
CI / test (push) Successful in 2m21s
CI / push-image (push) Successful in 6m24s
CI / deploy-ift (push) Successful in 18s
CI / ci-done (push) Successful in 0s
CI / e2e-ift (push) Successful in 57s
CI / deploy-stage (push) Successful in 5m26s
CI / e2e-stage (push) Successful in 1m12s
Удалены deploy/e2e workflow_run; workflow_dispatch input pipeline. Co-authored-by: Cursor <cursoragent@cursor.com>
417 lines
14 KiB
YAML
417 lines
14 KiB
YAML
name: CI
|
|
|
|
# PR / push: test + push образа (на push).
|
|
# push master/main: test → push-image → deploy IFT → E2E IFT → deploy stage → E2E stage (один run).
|
|
# workflow_dispatch: выбор фазы (см. input pipeline).
|
|
on:
|
|
push:
|
|
branches: [master, main]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
inputs:
|
|
pipeline:
|
|
description: "Режим (push master = full автоматически)"
|
|
required: false
|
|
default: full
|
|
type: choice
|
|
options:
|
|
- full
|
|
- test-only
|
|
- deploy-ift
|
|
- e2e-ift
|
|
- deploy-stage
|
|
- e2e-stage
|
|
|
|
concurrency:
|
|
group: eventhub-frontadmin-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
env:
|
|
BUILDKIT_PROGRESS: quiet
|
|
DOCKER_BUILDKIT: 1
|
|
REGISTRY: git.sabilin.com/eventhub
|
|
|
|
jobs:
|
|
test:
|
|
if: |
|
|
github.event_name == 'pull_request' ||
|
|
github.event_name == 'push' ||
|
|
(github.event_name == 'workflow_dispatch' && (github.event.inputs.pipeline == 'full' || github.event.inputs.pipeline == 'test-only'))
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
outputs:
|
|
ci_test_ok: ${{ steps.mark_test.outputs.ok }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Bake build identity
|
|
id: build_meta
|
|
run: |
|
|
set -euo pipefail
|
|
APP_VERSION="$(tr -d '[:space:]' < VERSION 2>/dev/null || echo 0.0)"
|
|
GIT_SHA="${GITHUB_SHA:0:12}"
|
|
BUILT_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
echo "VITE_APP_VERSION=${APP_VERSION}" >> "$GITHUB_ENV"
|
|
echo "VITE_GIT_SHA=${GIT_SHA}" >> "$GITHUB_ENV"
|
|
echo "VITE_BUILT_AT=${BUILT_AT}" >> "$GITHUB_ENV"
|
|
|
|
- run: npm ci
|
|
- run: npm run lint
|
|
- run: npm run build
|
|
|
|
- name: Install Playwright browser
|
|
run: bash scripts/install-playwright-chromium.sh
|
|
|
|
- name: E2E mock suite
|
|
run: npm run test:e2e
|
|
|
|
- name: Upload dist for docker job
|
|
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: admin-ui-dist
|
|
path: dist/
|
|
retention-days: 1
|
|
|
|
- name: Upload Playwright report
|
|
if: failure()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: playwright-report
|
|
path: playwright-report/
|
|
retention-days: 7
|
|
|
|
- name: Mark test complete
|
|
id: mark_test
|
|
if: success()
|
|
run: echo "ok=1" >> "$GITHUB_OUTPUT"
|
|
|
|
push-image:
|
|
needs: test
|
|
if: |
|
|
always() &&
|
|
needs.test.result == 'success' &&
|
|
needs.test.outputs.ci_test_ok == '1' &&
|
|
(
|
|
github.event_name == 'push' ||
|
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
|
|
)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
outputs:
|
|
ci_push_ok: ${{ steps.mark_push.outputs.ok }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download dist from test job
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: admin-ui-dist
|
|
path: dist
|
|
|
|
- name: Wait for Docker daemon
|
|
run: bash scripts/ensure-docker-daemon.sh 240
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build admin-ui image
|
|
run: |
|
|
set -euo pipefail
|
|
bash scripts/retry-docker-build.sh 5 60 -- \
|
|
docker buildx build \
|
|
--network=host \
|
|
--file Dockerfile \
|
|
--tag eventhub-admin-ui:local \
|
|
--load \
|
|
--provenance=false \
|
|
--sbom=false \
|
|
.
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: git.sabilin.com
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Push admin-ui image
|
|
run: |
|
|
set -euo pipefail
|
|
TAG="sha-${GITHUB_SHA:0:12}"
|
|
docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:${TAG}"
|
|
docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:ift"
|
|
docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:dev"
|
|
bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:${TAG}"
|
|
bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:ift"
|
|
bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:dev"
|
|
|
|
- name: Prune old registry images
|
|
continue-on-error: true
|
|
env:
|
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
run: bash scripts/run-registry-prune.sh
|
|
|
|
- name: Mark push complete
|
|
id: mark_push
|
|
if: success()
|
|
run: echo "ok=1" >> "$GITHUB_OUTPUT"
|
|
|
|
deploy-ift:
|
|
needs: push-image
|
|
if: |
|
|
always() && (
|
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'deploy-ift') ||
|
|
(
|
|
needs.push-image.result == 'success' &&
|
|
(
|
|
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')) ||
|
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
|
|
)
|
|
)
|
|
)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Compute image tag
|
|
id: meta
|
|
run: echo "tag=sha-${GITHUB_SHA:0:12}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Wait for Docker daemon
|
|
run: bash scripts/ensure-docker-daemon.sh 240
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: git.sabilin.com
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Verify admin-ui image from CI
|
|
run: |
|
|
set -euo pipefail
|
|
TAG="${{ steps.meta.outputs.tag }}"
|
|
if ! docker buildx imagetools inspect "${REGISTRY}/eventhub-admin-ui:${TAG}" >/dev/null 2>&1; then
|
|
echo "Образ eventhub-admin-ui:${TAG} не найден — test/push-image не завершились."
|
|
exit 1
|
|
fi
|
|
echo "OK: eventhub-admin-ui:${TAG}"
|
|
|
|
- name: Deploy admin on IFT via SSH
|
|
uses: appleboy/ssh-action@v0.1.5
|
|
with:
|
|
host: ${{ secrets.IFT_SSH_HOST }}
|
|
username: ${{ secrets.IFT_SSH_USER }}
|
|
key: ${{ secrets.IFT_SSH_PRIVATE_KEY }}
|
|
script: |
|
|
export REGISTRY_USER='${{ secrets.REGISTRY_USER }}'
|
|
export REGISTRY_PASSWORD='${{ secrets.REGISTRY_PASSWORD }}'
|
|
bash /opt/eventhub-ift/devops/scripts/deploy-service.sh ift admin ${{ steps.meta.outputs.tag }}
|
|
|
|
e2e-ift:
|
|
needs: deploy-ift
|
|
if: |
|
|
always() && (
|
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'e2e-ift') ||
|
|
(
|
|
needs.deploy-ift.result == 'success' &&
|
|
(
|
|
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')) ||
|
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
|
|
)
|
|
)
|
|
)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- run: npm ci
|
|
|
|
- name: Install Playwright browser
|
|
run: bash scripts/install-playwright-chromium.sh
|
|
|
|
- name: Load smoke credentials from IFT .env
|
|
env:
|
|
SSH_HOST: ${{ secrets.IFT_SSH_HOST }}
|
|
SSH_USER: ${{ secrets.IFT_SSH_USER }}
|
|
SSH_KEY: ${{ secrets.IFT_SSH_PRIVATE_KEY }}
|
|
run: bash scripts/load-stand-smoke-env.sh ift
|
|
|
|
- name: E2E IFT (integration, live API)
|
|
env:
|
|
E2E_TARGET: ift
|
|
E2E_IFT_BASE_URL: ${{ secrets.E2E_IFT_BASE_URL }}
|
|
run: npm run test:e2e:ift
|
|
|
|
- name: Upload Playwright report
|
|
if: failure()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: playwright-ift-report
|
|
path: playwright-report/
|
|
retention-days: 7
|
|
|
|
deploy-stage:
|
|
needs: e2e-ift
|
|
if: |
|
|
always() && (
|
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'deploy-stage') ||
|
|
(
|
|
needs.e2e-ift.result == 'success' &&
|
|
(
|
|
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')) ||
|
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
|
|
)
|
|
)
|
|
)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Compute image tag
|
|
id: meta
|
|
run: echo "tag=sha-${GITHUB_SHA:0:12}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Wait for Docker daemon
|
|
run: bash scripts/ensure-docker-daemon.sh 240
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: git.sabilin.com
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Verify admin-ui image from CI
|
|
run: |
|
|
set -euo pipefail
|
|
TAG="${{ steps.meta.outputs.tag }}"
|
|
if ! docker buildx imagetools inspect "${REGISTRY}/eventhub-admin-ui:${TAG}" >/dev/null 2>&1; then
|
|
echo "Образ eventhub-admin-ui:${TAG} не найден — test push не завершился."
|
|
exit 1
|
|
fi
|
|
echo "OK: eventhub-admin-ui:${TAG}"
|
|
|
|
- name: Promote sha → :stage (no rebuild)
|
|
env:
|
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
run: |
|
|
bash scripts/clone-devops-run.sh scripts/promote-images.sh \
|
|
"${{ steps.meta.outputs.tag }}" \
|
|
"${{ steps.meta.outputs.tag }}" \
|
|
stage \
|
|
eventhub-admin-ui
|
|
|
|
- name: Deploy admin on stage via SSH
|
|
uses: appleboy/ssh-action@v0.1.5
|
|
with:
|
|
host: ${{ secrets.STAGE_SSH_HOST }}
|
|
username: ${{ secrets.STAGE_SSH_USER }}
|
|
key: ${{ secrets.STAGE_SSH_PRIVATE_KEY }}
|
|
script: |
|
|
export REGISTRY_USER='${{ secrets.REGISTRY_USER }}'
|
|
export REGISTRY_PASSWORD='${{ secrets.REGISTRY_PASSWORD }}'
|
|
bash /opt/eventhub-stage/devops/scripts/deploy-service.sh stage admin ${{ steps.meta.outputs.tag }}
|
|
|
|
- name: Prune old registry images
|
|
continue-on-error: true
|
|
env:
|
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
run: bash scripts/clone-devops-run.sh scripts/prune-registry-images.sh
|
|
|
|
e2e-stage:
|
|
needs: deploy-stage
|
|
if: |
|
|
always() && (
|
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'e2e-stage') ||
|
|
(
|
|
needs.deploy-stage.result == 'success' &&
|
|
(
|
|
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')) ||
|
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
|
|
)
|
|
)
|
|
)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- run: npm ci
|
|
|
|
- name: Install Playwright browser
|
|
run: bash scripts/install-playwright-chromium.sh
|
|
|
|
- name: Load smoke credentials from stage .env
|
|
env:
|
|
SSH_HOST: ${{ secrets.STAGE_SSH_HOST }}
|
|
SSH_USER: ${{ secrets.STAGE_SSH_USER }}
|
|
SSH_KEY: ${{ secrets.STAGE_SSH_PRIVATE_KEY }}
|
|
run: bash scripts/load-stand-smoke-env.sh stage
|
|
|
|
- name: E2E stage (integration, live API)
|
|
env:
|
|
E2E_TARGET: stage
|
|
E2E_STAGE_BASE_URL: ${{ secrets.E2E_STAGE_BASE_URL }}
|
|
run: npm run test:e2e:stage
|
|
|
|
- name: Upload Playwright report
|
|
if: failure()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: playwright-stage-report
|
|
path: playwright-report/
|
|
retention-days: 7
|
|
|
|
ci-done:
|
|
needs: [test, push-image]
|
|
if: |
|
|
always() && (
|
|
github.event_name == 'pull_request' ||
|
|
github.event_name == 'push' ||
|
|
(github.event_name == 'workflow_dispatch' && (github.event.inputs.pipeline == 'full' || github.event.inputs.pipeline == 'test-only'))
|
|
)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- name: Enforce CI gate (test / push on push & PR)
|
|
run: |
|
|
set -euo pipefail
|
|
if [ "${{ needs.test.outputs.ci_test_ok }}" != "1" ]; then
|
|
echo "::error::test job incomplete"
|
|
exit 1
|
|
fi
|
|
if [ "${{ github.event_name }}" = "push" ] || ( [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.pipeline }}" = "full" ] ); then
|
|
if [ "${{ needs.push-image.result }}" != "success" ]; then
|
|
echo "::error::push-image must succeed, got: ${{ needs.push-image.result }}"
|
|
exit 1
|
|
fi
|
|
if [ "${{ needs.push-image.outputs.ci_push_ok }}" != "1" ]; then
|
|
echo "::error::push-image incomplete"
|
|
exit 1
|
|
fi
|
|
fi
|
|
echo "CI gate OK"
|