name: CI on: push: branches: [master, main] pull_request: workflow_dispatch: # Один runner (DESKTOP-SIR8B3R): параллельные workflow ломают кэш act/actions. concurrency: group: eventhub-frontadmin-ci-${{ github.ref }} cancel-in-progress: false env: BUILDKIT_PROGRESS: quiet DOCKER_BUILDKIT: 1 REGISTRY: git.sabilin.com/eventhub jobs: test: runs-on: ubuntu-latest timeout-minutes: 20 outputs: ci_test_ok: ${{ steps.mark_test.outputs.ok }} steps: - uses: actions/checkout@v4 # Без cache: npm — act_runner отменяет шаг на распаковке ~546MB (exit -1). - 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" echo "version=${APP_VERSION}" >> "$GITHUB_OUTPUT" echo "git_sha=${GIT_SHA}" >> "$GITHUB_OUTPUT" - 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' 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: github.event_name == 'push' && needs.test.outputs.ci_test_ok == '1' 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" ci-done: needs: [test, push-image] if: always() runs-on: ubuntu-latest timeout-minutes: 5 steps: - name: Enforce CI completion run: | set -euo pipefail TEST_OK="${{ needs.test.outputs.ci_test_ok }}" if [ "${TEST_OK}" != "1" ]; then echo "::error::test job incomplete (runner reported success without output)" exit 1 fi if [ "${{ github.event_name }}" = "push" ]; 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 (output missing)" exit 1 fi fi echo "CI gate OK"