CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m16s
CI / Check (pull_request) Failing after 9m8s
The first run of the job lost mongod mid-run again: its log says "Too many open files" (WiredTiger fatal assertion). Every test opens its own database, so WiredTiger keeps a file open per collection and index, and job containers start with a soft limit of 1024. Reproduced locally with --ulimit nofile=1024:524288 (19 of 87 failed); with 64000, all 87 pass. That also explains the lost mongo service containers in #584. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
443 lines
23 KiB
YAML
443 lines
23 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
env:
|
|
# registry + cosign creds via env, NOT inline ${{ }}: the Harbor robot
|
|
# username contains '$', which sh expands when interpolated into the
|
|
# script (robot$ci-push -> robot-push) => docker login unauthorized.
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
|
|
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
|
|
CARGO_TERM_COLOR: always
|
|
RUSTFLAGS: "-D warnings"
|
|
# Job containers on the OVH runners get --cpus=2 --memory=3g, but cargo sees
|
|
# the host's 8 cores and ran up to 8 rustc with full debug info: the dashboard
|
|
# build was OOM-killed (signal 9). Two jobs to match the CPUs, and line tables
|
|
# only (backtraces keep file:line, no full variable info).
|
|
CARGO_BUILD_JOBS: "2"
|
|
CARGO_PROFILE_DEV_DEBUG: line-tables-only
|
|
# Compile cache: sccache -> Hetzner S3 (breakpilot-sccache), runner-independent
|
|
# and persistent across CI runs (own key prefix). Reuses the shared cluster S3
|
|
# creds (same bucket as werkpilot). Requires repo secrets HETZNER_S3_ACCESS_KEY
|
|
# and HETZNER_S3_SECRET_KEY.
|
|
RUSTC_WRAPPER: /usr/local/bin/sccache
|
|
SCCACHE_BUCKET: bp-sccache
|
|
SCCACHE_ENDPOINT: https://nbg1.your-objectstorage.com
|
|
SCCACHE_REGION: auto
|
|
SCCACHE_S3_USE_SSL: "true"
|
|
SCCACHE_S3_KEY_PREFIX: compliance-scanner
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.HETZNER_S3_ACCESS_KEY }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.HETZNER_S3_SECRET_KEY }}
|
|
# compliance-agent depends on firmwerk-core via git; use the system git so the
|
|
# credential rewrite below (see "Configure git auth ...") is honored on fetch.
|
|
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
|
|
# Throttle cargo so a ~670-crate concurrent download burst doesn't 429 the
|
|
# Kellnr mirror: fewer concurrent connections (HTTP/1.1) + more retries.
|
|
CARGO_NET_RETRY: "10"
|
|
CARGO_HTTP_MULTIPLEXING: "false"
|
|
|
|
# Cancel superseded PR runs, but NEVER drop a main-branch run: each one deploys
|
|
# only the services its own commit changed, so a dropped run leaves a service
|
|
# un-deployed. `cancel-in-progress: false` is not enough, because a group keeps
|
|
# one pending run and cancels a queued one when the next merge lands. So main
|
|
# runs get a group per commit; the deploy jobs' own groups keep each service's
|
|
# deploys in merge order.
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 1: Lint, audit, and test (single job to share cargo cache)
|
|
# ---------------------------------------------------------------------------
|
|
check:
|
|
name: Check
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: docker
|
|
container:
|
|
image: rust:1.94-bookworm
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git init
|
|
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
|
git fetch --depth=1 origin "${GITHUB_SHA}"
|
|
git checkout FETCH_HEAD
|
|
# Resolve crates.io deps through the self-hosted Kellnr mirror (cached,
|
|
# crates.io-independent). Git deps (firmwerk-core) are unaffected — source
|
|
# replacement only applies to crates.io-sourced crates.
|
|
- name: Use Kellnr crates.io mirror
|
|
run: |
|
|
: "${CARGO_HOME:=/usr/local/cargo}"
|
|
mkdir -p "$CARGO_HOME"
|
|
{
|
|
echo '[source.crates-io]'
|
|
echo 'replace-with = "kellnr"'
|
|
echo '[registries.kellnr]'
|
|
echo 'index = "sparse+https://crates.breakpilot.com/api/v1/cratesio/"'
|
|
} >> "$CARGO_HOME/config.toml"
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
- name: Install tools
|
|
run: |
|
|
rustup component add rustfmt clippy
|
|
curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz \
|
|
| tar xz --strip-components=1 -C /usr/local/bin/ sccache-v0.10.0-x86_64-unknown-linux-musl/sccache
|
|
chmod +x /usr/local/bin/sccache
|
|
cargo install cargo-audit --locked
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
|
|
# compliance-agent has a git dependency on firmwerk-core (a private repo on
|
|
# this Gitea instance). Rewrite its SSH URL to HTTPS + a PAT so the runner
|
|
# can fetch it. Uses the org secret PLATFORM_CI_TOKEN (bot `platform-ci`,
|
|
# read-only member of the platform org).
|
|
# (Honored on fetch because CARGO_NET_GIT_FETCH_WITH_CLI=true uses system git.)
|
|
- name: Configure git auth for the private firmwerk dependency
|
|
run: |
|
|
git config --global \
|
|
url."https://platform-ci:${{ secrets.PLATFORM_CI_TOKEN }}@git.breakpilot.com/".insteadOf \
|
|
"ssh://git@git.breakpilot.com:22222/"
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
|
|
# Format (no compilation needed)
|
|
- name: Format
|
|
run: cargo fmt --all --check
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
|
|
# Clippy (compiles once, sccache reuses across feature sets). --all-targets
|
|
# lints test code too; tests may unwrap (clippy.toml), production may not.
|
|
- name: Clippy (core)
|
|
run: cargo clippy -p compliance-core --all-targets -- -D warnings
|
|
- name: Clippy (agent)
|
|
run: cargo clippy -p compliance-agent --all-targets -- -D warnings
|
|
- name: Clippy (dashboard server)
|
|
run: cargo clippy -p compliance-dashboard --features server --no-default-features --all-targets -- -D warnings
|
|
- name: Clippy (dashboard web)
|
|
run: cargo clippy -p compliance-dashboard --features web --no-default-features --all-targets -- -D warnings
|
|
- name: Clippy (mcp)
|
|
run: cargo clippy -p compliance-mcp --all-targets -- -D warnings
|
|
- name: Clippy (werkbank-exec)
|
|
run: cargo clippy -p werkbank-exec --all-targets -- -D warnings
|
|
- name: Clippy (control-map)
|
|
run: cargo clippy -p control-map --all-targets -- -D warnings
|
|
|
|
# Security audit
|
|
- name: Security Audit
|
|
run: cargo audit
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
|
|
# Tests (reuses compilation artifacts from clippy)
|
|
- name: Tests (core + agent + werkbank-exec + control-map)
|
|
run: cargo test -p compliance-core -p compliance-agent -p werkbank-exec -p control-map --lib
|
|
# compliance-core's integration tests need no services.
|
|
- name: Tests (core integration)
|
|
run: cargo test -p compliance-core --tests
|
|
- name: Tests (dashboard server)
|
|
run: cargo test -p compliance-dashboard --features server --no-default-features
|
|
- name: Tests (dashboard web)
|
|
run: cargo test -p compliance-dashboard --features web --no-default-features
|
|
|
|
- name: Show sccache stats
|
|
run: sccache --show-stats
|
|
if: always()
|
|
|
|
# compliance-agent's integration tests (compliance-agent/tests) need MongoDB.
|
|
# Every test opens its own database, so WiredTiger keeps a file open per
|
|
# collection and index: with the containers' default of 1024 open files
|
|
# mongod aborts mid-run ("Too many open files"), which is what took the
|
|
# mongo service down in #584. mongod runs as a process in this job
|
|
# container with a raised limit, and its log is printed when a test fails.
|
|
agent-integration:
|
|
name: Agent integration
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: docker
|
|
container:
|
|
image: rust:1.94-bookworm
|
|
env:
|
|
MONGODB_VERSION: "7.0.45"
|
|
MONGODB_SHA256: e97e79211a7106a065d9119039ead401f32cfbbfa1681977fdeba4b4a4bf1f63
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git init
|
|
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
|
git fetch --depth=1 origin "${GITHUB_SHA}"
|
|
git checkout FETCH_HEAD
|
|
- name: Use Kellnr crates.io mirror
|
|
run: |
|
|
: "${CARGO_HOME:=/usr/local/cargo}"
|
|
mkdir -p "$CARGO_HOME"
|
|
{
|
|
echo '[source.crates-io]'
|
|
echo 'replace-with = "kellnr"'
|
|
echo '[registries.kellnr]'
|
|
echo 'index = "sparse+https://crates.breakpilot.com/api/v1/cratesio/"'
|
|
} >> "$CARGO_HOME/config.toml"
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
- name: Install sccache
|
|
run: |
|
|
curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz \
|
|
| tar xz --strip-components=1 -C /usr/local/bin/ sccache-v0.10.0-x86_64-unknown-linux-musl/sccache
|
|
chmod +x /usr/local/bin/sccache
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
- name: Configure git auth for the private firmwerk dependency
|
|
run: |
|
|
git config --global \
|
|
url."https://platform-ci:${{ secrets.PLATFORM_CI_TOKEN }}@git.breakpilot.com/".insteadOf \
|
|
"ssh://git@git.breakpilot.com:22222/"
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
|
|
# Build first, so compiling and mongod never share the job's 3 GB.
|
|
- name: Build the agent integration tests
|
|
run: cargo test -p compliance-agent --test '*' --no-run
|
|
|
|
# The official Debian 12 build, checked against its sha256; a small
|
|
# WiredTiger cache, no auth (the job container is its only client).
|
|
- name: Start MongoDB
|
|
run: |
|
|
T="mongodb-linux-x86_64-debian12-${MONGODB_VERSION}"
|
|
curl -fsSL "https://fastdl.mongodb.org/linux/${T}.tgz" -o /tmp/mongodb.tgz
|
|
echo "${MONGODB_SHA256} /tmp/mongodb.tgz" | sha256sum -c -
|
|
tar -xzf /tmp/mongodb.tgz -C /opt
|
|
mkdir -p /tmp/mongo-db
|
|
ulimit -n 64000 2>/dev/null || ulimit -n "$(ulimit -Hn)"
|
|
echo "open files: soft $(ulimit -Sn), hard $(ulimit -Hn)"
|
|
"/opt/${T}/bin/mongod" --dbpath /tmp/mongo-db --bind_ip 127.0.0.1 --port 27017 \
|
|
--wiredTigerCacheSizeGB 0.25 --fork --logpath /tmp/mongod.log
|
|
for i in $(seq 1 30); do
|
|
if (exec 3<>/dev/tcp/127.0.0.1/27017) 2>/dev/null; then echo "mongod is up"; exit 0; fi
|
|
sleep 1
|
|
done
|
|
echo "mongod did not start"; tail -50 /tmp/mongod.log; exit 1
|
|
shell: bash
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
|
|
- name: Tests (agent integration)
|
|
run: cargo test -p compliance-agent --test '*'
|
|
env:
|
|
TEST_MONGODB_URI: mongodb://127.0.0.1:27017/
|
|
|
|
- name: MongoDB log
|
|
if: failure()
|
|
run: |
|
|
pgrep -a mongod || echo "mongod is not running"
|
|
tail -100 /tmp/mongod.log || true
|
|
env:
|
|
RUSTC_WRAPPER: ""
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 2: Deploy (only on main, after checks pass)
|
|
# Each service only deploys when its relevant files changed.
|
|
# ---------------------------------------------------------------------------
|
|
detect-changes:
|
|
name: Detect Changes
|
|
runs-on: docker
|
|
if: github.ref == 'refs/heads/main'
|
|
container:
|
|
image: alpine:latest
|
|
outputs:
|
|
agent: ${{ steps.changes.outputs.agent }}
|
|
dashboard: ${{ steps.changes.outputs.dashboard }}
|
|
docs: ${{ steps.changes.outputs.docs }}
|
|
mcp: ${{ steps.changes.outputs.mcp }}
|
|
steps:
|
|
- name: Install git
|
|
run: apk add --no-cache git
|
|
- name: Checkout
|
|
run: |
|
|
git init
|
|
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
|
git fetch --depth=2 origin "${GITHUB_SHA}"
|
|
git checkout FETCH_HEAD
|
|
- name: Detect changed paths
|
|
id: changes
|
|
run: |
|
|
CHANGED=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
|
|
echo "Changed files:"
|
|
echo "$CHANGED"
|
|
|
|
# Agent: core libs and the crates the agent links (werkbank-exec,
|
|
# control-map), agent code, agent Dockerfile and the helper scripts
|
|
# it copies from docker/, and the docs and README the help assistant
|
|
# answers from (baked into the image)
|
|
if echo "$CHANGED" | grep -qE '^(compliance-core/|compliance-agent/|compliance-graph/|compliance-dast/|werkbank-exec/|control-map/|docker/|Dockerfile\.agent|Cargo\.(toml|lock)|docs/|README\.md)'; then
|
|
echo "agent=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "agent=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
# Dashboard: core libs, dashboard code, dashboard Dockerfile, assets
|
|
if echo "$CHANGED" | grep -qE '^(compliance-core/|compliance-dashboard/|Dockerfile\.dashboard|Dioxus\.toml|assets/|bin/|Cargo\.(toml|lock))'; then
|
|
echo "dashboard=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "dashboard=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
# Docs: docs folder, docs Dockerfile
|
|
if echo "$CHANGED" | grep -qE '^(docs/|Dockerfile\.docs)'; then
|
|
echo "docs=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "docs=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
# MCP: core libs, mcp code, mcp Dockerfile
|
|
if echo "$CHANGED" | grep -qE '^(compliance-core/|compliance-mcp/|Dockerfile\.mcp|Cargo\.(toml|lock))'; then
|
|
echo "mcp=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "mcp=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
deploy-agent:
|
|
name: Deploy Agent
|
|
runs-on: docker
|
|
needs: [detect-changes]
|
|
if: needs.detect-changes.outputs.agent == 'true'
|
|
# One agent deploy at a time, in merge order. A queued one may be replaced
|
|
# by a newer one, which builds from a later main and so includes it.
|
|
concurrency:
|
|
group: deploy-agent
|
|
cancel-in-progress: false
|
|
container:
|
|
image: docker:27-cli
|
|
steps:
|
|
- name: Build, push and trigger orca redeploy
|
|
env:
|
|
# PAT for fetching the private firmwerk git dependency during the
|
|
# image build (injected as a BuildKit secret, never baked into a layer).
|
|
PLATFORM_CI_TOKEN: ${{ secrets.PLATFORM_CI_TOKEN }}
|
|
run: |
|
|
apk add --no-cache git curl openssl
|
|
git init && git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
|
git fetch --depth=1 origin "${GITHUB_SHA}" && git checkout FETCH_HEAD
|
|
# GET /api/v1/platform/version: the latest release tag without its v
|
|
# (the checkout is shallow, so fetch the history and tags first) and
|
|
# the commit. No tag → empty, and the agent reports its crate version.
|
|
git fetch --quiet --unshallow --tags origin || true
|
|
TAG=$(git describe --tags --abbrev=0 --match 'v[0-9]*' 2>/dev/null || true)
|
|
PRUEFWERK_VERSION="${TAG#v}"
|
|
echo "version: ${PRUEFWERK_VERSION:-crate} commit: ${GITHUB_SHA}"
|
|
IMAGE=repo.breakpilot.com/pruefwerk/compliance-agent
|
|
echo "$REGISTRY_PASSWORD" | docker login repo.breakpilot.com -u "$REGISTRY_USERNAME" --password-stdin
|
|
DOCKER_BUILDKIT=1 docker build --pull --secret id=git_token,env=PLATFORM_CI_TOKEN \
|
|
--build-arg PRUEFWERK_VERSION="${PRUEFWERK_VERSION}" \
|
|
--build-arg PRUEFWERK_COMMIT="${GITHUB_SHA}" \
|
|
-f Dockerfile.agent -t "$IMAGE:latest" -t "$IMAGE:${GITHUB_SHA}" .
|
|
docker push "$IMAGE:latest" && docker push "$IMAGE:${GITHUB_SHA}"
|
|
{ command -v cosign >/dev/null 2>&1 || curl -sSfLo /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64 || wget -qO /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64; } || echo "::warning::cosign fetch failed"
|
|
chmod +x /usr/local/bin/cosign 2>/dev/null || true
|
|
cosign sign --yes --key env://COSIGN_KEY "$IMAGE:latest" || echo "::warning::cosign failed"
|
|
PAYLOAD=$(printf '{"ref":"refs/heads/main","repository":{"full_name":"platform/pruefwerk"},"head_commit":{"id":"%s","message":"deploy agent"}}' "${GITHUB_SHA}")
|
|
if [ -z "${{ vars.ORCA_WEBHOOK_URL }}" ]; then echo "::notice::ORCA_WEBHOOK_URL not set — image pushed, no redeploy triggered"; exit 0; fi
|
|
SIG=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "${{ secrets.ORCA_WEBHOOK_SECRET }}" | awk '{print $2}')
|
|
RESP=$(curl -fsS -w "\nHTTP %{http_code}" -X POST "${{ vars.ORCA_WEBHOOK_URL }}" -H "Content-Type: application/json" -H "X-Hub-Signature-256: sha256=$SIG" -d "$PAYLOAD"); echo "$RESP"
|
|
|
|
deploy-dashboard:
|
|
name: Deploy Dashboard
|
|
runs-on: docker
|
|
needs: [detect-changes]
|
|
if: needs.detect-changes.outputs.dashboard == 'true'
|
|
# One dashboard deploy at a time, in merge order. A queued one may be replaced
|
|
# by a newer one, which builds from a later main and so includes it.
|
|
concurrency:
|
|
group: deploy-dashboard
|
|
cancel-in-progress: false
|
|
container:
|
|
image: docker:27-cli
|
|
steps:
|
|
- name: Build, push and trigger orca redeploy
|
|
env:
|
|
PLATFORM_CI_TOKEN: ${{ secrets.PLATFORM_CI_TOKEN }}
|
|
run: |
|
|
apk add --no-cache git curl openssl
|
|
git init && git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
|
git fetch --depth=1 origin "${GITHUB_SHA}" && git checkout FETCH_HEAD
|
|
IMAGE=repo.breakpilot.com/pruefwerk/compliance-dashboard
|
|
echo "$REGISTRY_PASSWORD" | docker login repo.breakpilot.com -u "$REGISTRY_USERNAME" --password-stdin
|
|
DOCKER_BUILDKIT=1 docker build --pull --secret id=git_token,env=PLATFORM_CI_TOKEN \
|
|
-f Dockerfile.dashboard -t "$IMAGE:latest" -t "$IMAGE:${GITHUB_SHA}" .
|
|
docker push "$IMAGE:latest" && docker push "$IMAGE:${GITHUB_SHA}"
|
|
{ command -v cosign >/dev/null 2>&1 || curl -sSfLo /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64 || wget -qO /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64; } || echo "::warning::cosign fetch failed"
|
|
chmod +x /usr/local/bin/cosign 2>/dev/null || true
|
|
cosign sign --yes --key env://COSIGN_KEY "$IMAGE:latest" || echo "::warning::cosign failed"
|
|
PAYLOAD=$(printf '{"ref":"refs/heads/main","repository":{"full_name":"platform/pruefwerk"},"head_commit":{"id":"%s","message":"deploy dashboard"}}' "${GITHUB_SHA}")
|
|
if [ -z "${{ vars.ORCA_WEBHOOK_URL }}" ]; then echo "::notice::ORCA_WEBHOOK_URL not set — image pushed, no redeploy triggered"; exit 0; fi
|
|
SIG=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "${{ secrets.ORCA_WEBHOOK_SECRET }}" | awk '{print $2}')
|
|
RESP=$(curl -fsS -w "\nHTTP %{http_code}" -X POST "${{ vars.ORCA_WEBHOOK_URL }}" -H "Content-Type: application/json" -H "X-Hub-Signature-256: sha256=$SIG" -d "$PAYLOAD"); echo "$RESP"
|
|
|
|
deploy-docs:
|
|
name: Deploy Docs
|
|
runs-on: docker
|
|
needs: [detect-changes]
|
|
if: needs.detect-changes.outputs.docs == 'true'
|
|
# One docs deploy at a time, in merge order. A queued one may be replaced
|
|
# by a newer one, which builds from a later main and so includes it.
|
|
concurrency:
|
|
group: deploy-docs
|
|
cancel-in-progress: false
|
|
container:
|
|
image: docker:27-cli
|
|
steps:
|
|
- name: Build, push and trigger orca redeploy
|
|
run: |
|
|
apk add --no-cache git curl openssl
|
|
git init && git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
|
git fetch --depth=1 origin "${GITHUB_SHA}" && git checkout FETCH_HEAD
|
|
IMAGE=repo.breakpilot.com/pruefwerk/compliance-docs
|
|
echo "$REGISTRY_PASSWORD" | docker login repo.breakpilot.com -u "$REGISTRY_USERNAME" --password-stdin
|
|
docker build --pull -f Dockerfile.docs -t "$IMAGE:latest" -t "$IMAGE:${GITHUB_SHA}" .
|
|
docker push "$IMAGE:latest" && docker push "$IMAGE:${GITHUB_SHA}"
|
|
{ command -v cosign >/dev/null 2>&1 || curl -sSfLo /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64 || wget -qO /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64; } || echo "::warning::cosign fetch failed"
|
|
chmod +x /usr/local/bin/cosign 2>/dev/null || true
|
|
cosign sign --yes --key env://COSIGN_KEY "$IMAGE:latest" || echo "::warning::cosign failed"
|
|
PAYLOAD=$(printf '{"ref":"refs/heads/main","repository":{"full_name":"platform/pruefwerk"},"head_commit":{"id":"%s","message":"deploy docs"}}' "${GITHUB_SHA}")
|
|
if [ -z "${{ vars.ORCA_WEBHOOK_URL }}" ]; then echo "::notice::ORCA_WEBHOOK_URL not set — image pushed, no redeploy triggered"; exit 0; fi
|
|
SIG=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "${{ secrets.ORCA_WEBHOOK_SECRET }}" | awk '{print $2}')
|
|
RESP=$(curl -fsS -w "\nHTTP %{http_code}" -X POST "${{ vars.ORCA_WEBHOOK_URL }}" -H "Content-Type: application/json" -H "X-Hub-Signature-256: sha256=$SIG" -d "$PAYLOAD"); echo "$RESP"
|
|
|
|
deploy-mcp:
|
|
name: Deploy MCP
|
|
runs-on: docker
|
|
needs: [detect-changes]
|
|
if: needs.detect-changes.outputs.mcp == 'true'
|
|
# One mcp deploy at a time, in merge order. A queued one may be replaced
|
|
# by a newer one, which builds from a later main and so includes it.
|
|
concurrency:
|
|
group: deploy-mcp
|
|
cancel-in-progress: false
|
|
container:
|
|
image: docker:27-cli
|
|
steps:
|
|
- name: Build, push and trigger orca redeploy
|
|
env:
|
|
PLATFORM_CI_TOKEN: ${{ secrets.PLATFORM_CI_TOKEN }}
|
|
run: |
|
|
apk add --no-cache git curl openssl
|
|
git init && git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
|
git fetch --depth=1 origin "${GITHUB_SHA}" && git checkout FETCH_HEAD
|
|
IMAGE=repo.breakpilot.com/pruefwerk/compliance-mcp
|
|
echo "$REGISTRY_PASSWORD" | docker login repo.breakpilot.com -u "$REGISTRY_USERNAME" --password-stdin
|
|
DOCKER_BUILDKIT=1 docker build --pull --secret id=git_token,env=PLATFORM_CI_TOKEN \
|
|
-f Dockerfile.mcp -t "$IMAGE:latest" -t "$IMAGE:${GITHUB_SHA}" .
|
|
docker push "$IMAGE:latest" && docker push "$IMAGE:${GITHUB_SHA}"
|
|
{ command -v cosign >/dev/null 2>&1 || curl -sSfLo /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64 || wget -qO /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64; } || echo "::warning::cosign fetch failed"
|
|
chmod +x /usr/local/bin/cosign 2>/dev/null || true
|
|
cosign sign --yes --key env://COSIGN_KEY "$IMAGE:latest" || echo "::warning::cosign failed"
|
|
PAYLOAD=$(printf '{"ref":"refs/heads/main","repository":{"full_name":"platform/pruefwerk"},"head_commit":{"id":"%s","message":"deploy mcp"}}' "${GITHUB_SHA}")
|
|
if [ -z "${{ vars.ORCA_WEBHOOK_URL }}" ]; then echo "::notice::ORCA_WEBHOOK_URL not set — image pushed, no redeploy triggered"; exit 0; fi
|
|
SIG=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "${{ secrets.ORCA_WEBHOOK_SECRET }}" | awk '{print $2}')
|
|
RESP=$(curl -fsS -w "\nHTTP %{http_code}" -X POST "${{ vars.ORCA_WEBHOOK_URL }}" -H "Content-Type: application/json" -H "X-Hub-Signature-256: sha256=$SIG" -d "$PAYLOAD"); echo "$RESP"
|