nxtgauge-backend-rust/.forgejo/workflows/build.yaml
Ashwin Kumar Sivakumar 0d35bf5649
Some checks failed
build-and-push / detect-changes (push) Successful in 2s
build-and-push / build (catering-services) (push) Failing after 2s
build-and-push / build (companies) (push) Failing after 4s
build-and-push / build (cron) (push) Failing after 3s
build-and-push / build (developers) (push) Failing after 3s
build-and-push / build (customers) (push) Failing after 4s
build-and-push / build (employees) (push) Failing after 3s
build-and-push / build (fitness-trainers) (push) Failing after 4s
build-and-push / build (gateway) (push) Failing after 3s
build-and-push / build (job-seekers) (push) Failing after 3s
build-and-push / build (graphic-designers) (push) Failing after 4s
build-and-push / build (jobs) (push) Failing after 2s
build-and-push / build (leads) (push) Failing after 4s
build-and-push / build (makeup-artists) (push) Failing after 3s
build-and-push / build (payments) (push) Failing after 3s
build-and-push / build (photographers) (push) Failing after 3s
build-and-push / build (tutors) (push) Failing after 3s
build-and-push / build (social-media-managers) (push) Failing after 4s
build-and-push / build (ugc-content-creators) (push) Failing after 3s
build-and-push / build (users) (push) Failing after 4s
build-and-push / build (video-editors) (push) Failing after 3s
trigger build: rebuild all services
2026-06-13 01:23:22 +05:30

168 lines
5.8 KiB
YAML

name: build-and-push
on:
push:
branches:
- main
- high-performance
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
services_csv: ${{ steps.detect.outputs.services_csv }}
has_changes: ${{ steps.detect.outputs.has_changes }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed services
id: detect
run: |
set -euo pipefail
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
else
CHANGED_FILES=$(git ls-files)
fi
LAST_COMMIT_MSG=$(git log -1 --pretty=%B | tr '\n' ' ')
echo "Changed files:"
echo "$CHANGED_FILES"
ALL_SERVICES='gateway,users,companies,jobs,leads,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'
# Force full build for explicit trigger commits
if echo "$LAST_COMMIT_MSG" | grep -Eiq 'trigger build|force build|rebuild all'; then
echo "services_csv=$ALL_SERVICES" >> "$GITHUB_OUTPUT"
echo "has_changes=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Build everything for workflow/docker/shared backend changes
if echo "$CHANGED_FILES" | grep -Eq '^(\.forgejo/workflows/|Dockerfile|Cargo\.toml|Cargo\.lock|crates/)'; then
echo "services_csv=$ALL_SERVICES" >> "$GITHUB_OUTPUT"
echo "has_changes=true" >> "$GITHUB_OUTPUT"
exit 0
fi
SERVICES=''
add_service() {
local svc="$1"
case ",${SERVICES}," in
*",${svc},"*) ;;
*)
if [ -z "$SERVICES" ]; then
SERVICES="$svc"
else
SERVICES="$SERVICES,$svc"
fi
;;
esac
}
while IFS= read -r f; do
case "$f" in
apps/gateway/*) add_service "gateway" ;;
apps/users/*) add_service "users" ;;
apps/companies/*) add_service "companies" ;;
apps/jobs/*) add_service "jobs" ;;
apps/leads/*) add_service "leads" ;;
apps/job_seekers/*) add_service "job-seekers" ;;
apps/customers/*) add_service "customers" ;;
apps/payments/*) add_service "payments" ;;
apps/employees/*) add_service "employees" ;;
apps/photographers/*) add_service "photographers" ;;
apps/makeup_artists/*) add_service "makeup-artists" ;;
apps/tutors/*) add_service "tutors" ;;
apps/developers/*) add_service "developers" ;;
apps/video_editors/*) add_service "video-editors" ;;
apps/graphic_designers/*) add_service "graphic-designers" ;;
apps/social_media_managers/*) add_service "social-media-managers" ;;
apps/fitness_trainers/*) add_service "fitness-trainers" ;;
apps/catering_services/*) add_service "catering-services" ;;
apps/ugc_content_creators/*) add_service "ugc-content-creators" ;;
apps/cron/*) add_service "cron" ;;
esac
done <<< "$CHANGED_FILES"
if [ -z "$SERVICES" ]; then
echo "services_csv=" >> "$GITHUB_OUTPUT"
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "services_csv=$SERVICES" >> "$GITHUB_OUTPUT"
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
build:
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
env:
DOCKER_HOST: unix:///var/run/docker.sock
strategy:
fail-fast: false
matrix:
service:
- gateway
- users
- companies
- jobs
- leads
- 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: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
run: |
export DOCKER_HOST=unix:///var/run/docker.sock
docker version
docker buildx create --use || true
docker buildx inspect --bootstrap
- name: Login to Registry
run: |
set -euo pipefail
export DOCKER_HOST=unix:///var/run/docker.sock
echo "Logging into registry.nxtgauge.com..."
echo "Ashwin@2026" | docker login registry.nxtgauge.com -u admin --password-stdin
- name: Build and push
env:
SERVICES_CSV: ${{ needs.detect-changes.outputs.services_csv }}
run: |
set -euo pipefail
export DOCKER_HOST=unix:///var/run/docker.sock
SHA="${{ github.sha }}"
if [ -n "$SERVICES_CSV" ] && ! echo ",$SERVICES_CSV," | grep -q ",${{ matrix.service }},"; then
echo "Skipping unchanged service: ${{ matrix.service }}"
exit 0
fi
echo "Building ${{ matrix.service }}..."
docker buildx build --push \
-f Dockerfile.simple \
--build-arg SERVICE_NAME=${{ matrix.service }} \
-t "registry.nxtgauge.com/nxtgauge-rust-${{ matrix.service }}:${SHA}" \
-t "registry.nxtgauge.com/nxtgauge-rust-${{ matrix.service }}:latest" \
.