15646fe034
После split test/push-image dist не передаётся между jobs — COPY dist падал. Lint уже в test; здесь только npm ci + build. Co-authored-by: Cursor <cursoragent@cursor.com>
137 lines
4.3 KiB
YAML
137 lines
4.3 KiB
YAML
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 v1.0.8 отменяет шаг на распаковке ~546MB (exit -1).
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- run: npm ci
|
|
- run: npm run lint
|
|
- run: npm run build
|
|
|
|
- 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
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Build frontend (dist for Dockerfile)
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
|
|
- 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"
|
|
|
|
# act_runner v1.0.8: cancelled steps не валят job; gate-шаги if:always() не выполняются.
|
|
# Отдельный job проверяет outputs/result — workflow = failure, deploy-ift не стартует.
|
|
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"
|