102 lines
2.6 KiB
YAML
102 lines
2.6 KiB
YAML
when:
|
|
branch: [main, high-performance]
|
|
event: push
|
|
|
|
matrix:
|
|
SERVICE:
|
|
- gateway
|
|
- users
|
|
- companies
|
|
- job_seekers
|
|
- customers
|
|
- payments
|
|
- employees
|
|
- photographers
|
|
- makeup_artists
|
|
- tutors
|
|
- developers
|
|
- video_editors
|
|
- graphic_designers
|
|
- social_media_managers
|
|
- fitness_trainers
|
|
- catering_services
|
|
- ugc_content_creators
|
|
- cron
|
|
|
|
steps:
|
|
- name: detect-changes
|
|
image: alpine/git
|
|
commands:
|
|
- apk add --no-cache bash
|
|
- |
|
|
#!/bin/bash
|
|
set -e
|
|
|
|
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD || echo "")
|
|
SERVICE_PATH=$(echo "${SERVICE}" | tr '_' '-')
|
|
|
|
SHARED_CHANGED=false
|
|
if echo "$CHANGED_FILES" | grep -q "^crates/"; then
|
|
SHARED_CHANGED=true
|
|
echo "⚠️ Shared crates changed"
|
|
fi
|
|
|
|
SERVICE_CHANGED=false
|
|
if echo "$CHANGED_FILES" | grep -q "^apps/${SERVICE_PATH}/"; then
|
|
SERVICE_CHANGED=true
|
|
echo "✅ Service ${SERVICE} changed"
|
|
fi
|
|
|
|
if [ "$SHARED_CHANGED" = "true" ] || [ "$SERVICE_CHANGED" = "true" ]; then
|
|
echo "🚀 Building ${SERVICE}"
|
|
exit 0
|
|
else
|
|
echo "⏭️ Skipping ${SERVICE}"
|
|
exit 78
|
|
fi
|
|
|
|
- name: build
|
|
image: rust:alpine
|
|
commands:
|
|
- apk add --no-cache musl-dev pkgconfig openssl-dev git
|
|
- rustup target add x86_64-unknown-linux-musl
|
|
- |
|
|
#!/bin/bash
|
|
set -e
|
|
|
|
# Build static binary directly (no Docker!)
|
|
cd /woodpecker/src/git
|
|
|
|
# Copy only needed files for this service
|
|
mkdir -p /tmp/build
|
|
cp -r Cargo.toml Cargo.lock crates/ /tmp/build/
|
|
cp -r apps/${SERVICE}/ /tmp/build/apps/
|
|
cd /tmp/build
|
|
|
|
# Build with optimizations
|
|
export RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-s"
|
|
cargo build --release \
|
|
--bin ${SERVICE} \
|
|
--target x86_64-unknown-linux-musl
|
|
|
|
# Copy binary to workspace for next step
|
|
cp target/x86_64-unknown-linux-musl/release/${SERVICE} /woodpecker/src/git/${SERVICE}-binary
|
|
|
|
echo "✅ Binary built successfully"
|
|
|
|
- name: build-docker
|
|
image: woodpeckerci/plugin-docker-buildx:5.0.0
|
|
settings:
|
|
registry: registry.nxtgauge.com
|
|
repo: nxtgauge-rust-${SERVICE}
|
|
dockerfile: Dockerfile.binary
|
|
build_args:
|
|
- SERVICE_NAME=${SERVICE}
|
|
tags:
|
|
- ${CI_COMMIT_SHA}
|
|
- latest
|
|
username:
|
|
from_secret: REGISTRY_USERNAME
|
|
password:
|
|
from_secret: REGISTRY_PASSWORD
|
|
platforms: linux/amd64
|