mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 19:01:08 +02:00
- Add notify-start job with Telegram notification for build start - Add notify-complete job with build status and duration notification - Push CI metrics to Prometheus Pushgateway for Grafana visualization - Create CI/CD Grafana dashboard with build status, duration, and history - Add Pushgateway scrape config to Prometheus Requires TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, and PUSHGATEWAY_URL secrets. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1178 lines
46 KiB
YAML
1178 lines
46 KiB
YAML
# CI Pipeline: Validates code on PRs, builds images on push
|
|
#
|
|
# Flow:
|
|
# PR → dev/main : Runs validation (required status check)
|
|
# Push → dev/main : Builds Docker images (only changed services)
|
|
#
|
|
# Selective Builds:
|
|
# - Only builds services that have changed files
|
|
# - Detects changes in service path, shared packages, and root config
|
|
# - Use workflow_dispatch to force rebuild all services
|
|
#
|
|
# Deployments are triggered separately:
|
|
# - Manual: workflow_dispatch on cd-staging.yml / cd-production.yml
|
|
# - Tag-based: push tag like "chat-staging-v1.0.0" triggers cd-staging-tagged.yml
|
|
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- dev
|
|
workflow_dispatch:
|
|
inputs:
|
|
force_build_all:
|
|
description: 'Force rebuild all services'
|
|
required: false
|
|
default: 'false'
|
|
type: boolean
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
NODE_VERSION: '20'
|
|
PNPM_VERSION: '9.15.0'
|
|
|
|
jobs:
|
|
# ===========================================
|
|
# Detect Changes - determines which services to build
|
|
# ===========================================
|
|
detect-changes:
|
|
name: Detect Changes
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
|
outputs:
|
|
mana-core-auth: ${{ steps.changes.outputs.mana-core-auth }}
|
|
manacore-web: ${{ steps.changes.outputs.manacore-web }}
|
|
chat-backend: ${{ steps.changes.outputs.chat-backend }}
|
|
chat-web: ${{ steps.changes.outputs.chat-web }}
|
|
todo-backend: ${{ steps.changes.outputs.todo-backend }}
|
|
todo-web: ${{ steps.changes.outputs.todo-web }}
|
|
calendar-backend: ${{ steps.changes.outputs.calendar-backend }}
|
|
calendar-web: ${{ steps.changes.outputs.calendar-web }}
|
|
clock-backend: ${{ steps.changes.outputs.clock-backend }}
|
|
clock-web: ${{ steps.changes.outputs.clock-web }}
|
|
contacts-backend: ${{ steps.changes.outputs.contacts-backend }}
|
|
contacts-web: ${{ steps.changes.outputs.contacts-web }}
|
|
presi-backend: ${{ steps.changes.outputs.presi-backend }}
|
|
presi-web: ${{ steps.changes.outputs.presi-web }}
|
|
storage-backend: ${{ steps.changes.outputs.storage-backend }}
|
|
storage-web: ${{ steps.changes.outputs.storage-web }}
|
|
telegram-stats-bot: ${{ steps.changes.outputs.telegram-stats-bot }}
|
|
any-changes: ${{ steps.changes.outputs.any-changes }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Check for changes
|
|
id: changes
|
|
run: |
|
|
# Force build all if workflow_dispatch with force_build_all
|
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ "${{ inputs.force_build_all }}" == "true" ]; then
|
|
echo "Force rebuild all services requested"
|
|
echo "mana-core-auth=true" >> $GITHUB_OUTPUT
|
|
echo "manacore-web=true" >> $GITHUB_OUTPUT
|
|
echo "chat-backend=true" >> $GITHUB_OUTPUT
|
|
echo "chat-web=true" >> $GITHUB_OUTPUT
|
|
echo "todo-backend=true" >> $GITHUB_OUTPUT
|
|
echo "todo-web=true" >> $GITHUB_OUTPUT
|
|
echo "calendar-backend=true" >> $GITHUB_OUTPUT
|
|
echo "calendar-web=true" >> $GITHUB_OUTPUT
|
|
echo "clock-backend=true" >> $GITHUB_OUTPUT
|
|
echo "clock-web=true" >> $GITHUB_OUTPUT
|
|
echo "contacts-backend=true" >> $GITHUB_OUTPUT
|
|
echo "contacts-web=true" >> $GITHUB_OUTPUT
|
|
echo "presi-backend=true" >> $GITHUB_OUTPUT
|
|
echo "presi-web=true" >> $GITHUB_OUTPUT
|
|
echo "storage-backend=true" >> $GITHUB_OUTPUT
|
|
echo "storage-web=true" >> $GITHUB_OUTPUT
|
|
echo "telegram-stats-bot=true" >> $GITHUB_OUTPUT
|
|
echo "any-changes=true" >> $GITHUB_OUTPUT
|
|
exit 0
|
|
fi
|
|
|
|
# Get changed files between current commit and previous
|
|
if [ "${{ github.event_name }}" == "push" ]; then
|
|
BASE_SHA="${{ github.event.before }}"
|
|
HEAD_SHA="${{ github.sha }}"
|
|
# Handle initial commit case
|
|
if [ "$BASE_SHA" == "0000000000000000000000000000000000000000" ]; then
|
|
CHANGED_FILES=$(git ls-files)
|
|
else
|
|
CHANGED_FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA 2>/dev/null || git ls-files)
|
|
fi
|
|
else
|
|
# workflow_dispatch without force - build all
|
|
echo "Workflow dispatch without force_build_all - building all"
|
|
echo "mana-core-auth=true" >> $GITHUB_OUTPUT
|
|
echo "manacore-web=true" >> $GITHUB_OUTPUT
|
|
echo "chat-backend=true" >> $GITHUB_OUTPUT
|
|
echo "chat-web=true" >> $GITHUB_OUTPUT
|
|
echo "todo-backend=true" >> $GITHUB_OUTPUT
|
|
echo "todo-web=true" >> $GITHUB_OUTPUT
|
|
echo "calendar-backend=true" >> $GITHUB_OUTPUT
|
|
echo "calendar-web=true" >> $GITHUB_OUTPUT
|
|
echo "clock-backend=true" >> $GITHUB_OUTPUT
|
|
echo "clock-web=true" >> $GITHUB_OUTPUT
|
|
echo "contacts-backend=true" >> $GITHUB_OUTPUT
|
|
echo "contacts-web=true" >> $GITHUB_OUTPUT
|
|
echo "presi-backend=true" >> $GITHUB_OUTPUT
|
|
echo "presi-web=true" >> $GITHUB_OUTPUT
|
|
echo "storage-backend=true" >> $GITHUB_OUTPUT
|
|
echo "storage-web=true" >> $GITHUB_OUTPUT
|
|
echo "telegram-stats-bot=true" >> $GITHUB_OUTPUT
|
|
echo "any-changes=true" >> $GITHUB_OUTPUT
|
|
exit 0
|
|
fi
|
|
|
|
echo "Changed files:"
|
|
echo "$CHANGED_FILES"
|
|
|
|
# Common files that trigger all builds
|
|
COMMON_PATTERNS="pnpm-lock.yaml|pnpm-workspace.yaml|package.json|.github/workflows/ci.yml"
|
|
|
|
# Shared packages that affect multiple services
|
|
SHARED_AUTH_PATTERN="packages/shared-auth/|packages/shared-types/"
|
|
SHARED_UI_PATTERN="packages/shared-ui/|packages/shared-theme/|packages/shared-icons/|packages/shared-tailwind/|packages/shared-branding/"
|
|
SHARED_WEB_PATTERN="packages/shared-auth-ui/|packages/shared-theme-ui/|packages/shared-feedback-ui/|packages/shared-profile-ui/|packages/shared-subscription-ui/|packages/shared-splitscreen/"
|
|
|
|
# Function to check if any pattern matches
|
|
check_pattern() {
|
|
echo "$CHANGED_FILES" | grep -qE "$1" && echo "true" || echo "false"
|
|
}
|
|
|
|
# Check common changes
|
|
COMMON_CHANGED=$(check_pattern "$COMMON_PATTERNS")
|
|
SHARED_AUTH_CHANGED=$(check_pattern "$SHARED_AUTH_PATTERN")
|
|
SHARED_UI_CHANGED=$(check_pattern "$SHARED_UI_PATTERN")
|
|
SHARED_WEB_CHANGED=$(check_pattern "$SHARED_WEB_PATTERN")
|
|
|
|
echo "Common changed: $COMMON_CHANGED"
|
|
echo "Shared auth changed: $SHARED_AUTH_CHANGED"
|
|
echo "Shared UI changed: $SHARED_UI_CHANGED"
|
|
echo "Shared web changed: $SHARED_WEB_CHANGED"
|
|
|
|
# mana-core-auth: services/mana-core-auth + packages/shared-nestjs-auth
|
|
AUTH_CHANGED=$(check_pattern "services/mana-core-auth/|packages/shared-nestjs-auth/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$AUTH_CHANGED" == "true" ]; then
|
|
echo "mana-core-auth=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "mana-core-auth=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# manacore-web: apps/manacore/apps/web + shared packages
|
|
MANACORE_WEB_CHANGED=$(check_pattern "apps/manacore/apps/web/|apps/manacore/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$SHARED_UI_CHANGED" == "true" ] || [ "$SHARED_WEB_CHANGED" == "true" ] || [ "$MANACORE_WEB_CHANGED" == "true" ]; then
|
|
echo "manacore-web=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "manacore-web=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# chat-backend: apps/chat/apps/backend + packages
|
|
CHAT_BACKEND_CHANGED=$(check_pattern "apps/chat/apps/backend/|apps/chat/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$CHAT_BACKEND_CHANGED" == "true" ]; then
|
|
echo "chat-backend=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "chat-backend=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# chat-web: apps/chat/apps/web + packages + shared web
|
|
CHAT_WEB_CHANGED=$(check_pattern "apps/chat/apps/web/|apps/chat/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$SHARED_UI_CHANGED" == "true" ] || [ "$SHARED_WEB_CHANGED" == "true" ] || [ "$CHAT_WEB_CHANGED" == "true" ]; then
|
|
echo "chat-web=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "chat-web=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# todo-backend
|
|
TODO_BACKEND_CHANGED=$(check_pattern "apps/todo/apps/backend/|apps/todo/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$TODO_BACKEND_CHANGED" == "true" ]; then
|
|
echo "todo-backend=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "todo-backend=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# todo-web
|
|
TODO_WEB_CHANGED=$(check_pattern "apps/todo/apps/web/|apps/todo/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$SHARED_UI_CHANGED" == "true" ] || [ "$SHARED_WEB_CHANGED" == "true" ] || [ "$TODO_WEB_CHANGED" == "true" ]; then
|
|
echo "todo-web=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "todo-web=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# calendar-backend
|
|
CALENDAR_BACKEND_CHANGED=$(check_pattern "apps/calendar/apps/backend/|apps/calendar/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$CALENDAR_BACKEND_CHANGED" == "true" ]; then
|
|
echo "calendar-backend=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "calendar-backend=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# calendar-web
|
|
CALENDAR_WEB_CHANGED=$(check_pattern "apps/calendar/apps/web/|apps/calendar/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$SHARED_UI_CHANGED" == "true" ] || [ "$SHARED_WEB_CHANGED" == "true" ] || [ "$CALENDAR_WEB_CHANGED" == "true" ]; then
|
|
echo "calendar-web=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "calendar-web=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# clock-backend
|
|
CLOCK_BACKEND_CHANGED=$(check_pattern "apps/clock/apps/backend/|apps/clock/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$CLOCK_BACKEND_CHANGED" == "true" ]; then
|
|
echo "clock-backend=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "clock-backend=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# clock-web
|
|
CLOCK_WEB_CHANGED=$(check_pattern "apps/clock/apps/web/|apps/clock/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$SHARED_UI_CHANGED" == "true" ] || [ "$SHARED_WEB_CHANGED" == "true" ] || [ "$CLOCK_WEB_CHANGED" == "true" ]; then
|
|
echo "clock-web=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "clock-web=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# contacts-backend
|
|
CONTACTS_BACKEND_CHANGED=$(check_pattern "apps/contacts/apps/backend/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$CONTACTS_BACKEND_CHANGED" == "true" ]; then
|
|
echo "contacts-backend=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "contacts-backend=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# contacts-web
|
|
CONTACTS_WEB_CHANGED=$(check_pattern "apps/contacts/apps/web/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$SHARED_UI_CHANGED" == "true" ] || [ "$SHARED_WEB_CHANGED" == "true" ] || [ "$CONTACTS_WEB_CHANGED" == "true" ]; then
|
|
echo "contacts-web=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "contacts-web=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# presi-backend
|
|
PRESI_BACKEND_CHANGED=$(check_pattern "apps/presi/apps/backend/|apps/presi/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$PRESI_BACKEND_CHANGED" == "true" ]; then
|
|
echo "presi-backend=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "presi-backend=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# presi-web
|
|
PRESI_WEB_CHANGED=$(check_pattern "apps/presi/apps/web/|apps/presi/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$SHARED_UI_CHANGED" == "true" ] || [ "$SHARED_WEB_CHANGED" == "true" ] || [ "$PRESI_WEB_CHANGED" == "true" ]; then
|
|
echo "presi-web=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "presi-web=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# storage-backend
|
|
STORAGE_BACKEND_CHANGED=$(check_pattern "apps/storage/apps/backend/|apps/storage/packages/|packages/shared-storage/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$STORAGE_BACKEND_CHANGED" == "true" ]; then
|
|
echo "storage-backend=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "storage-backend=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# storage-web
|
|
STORAGE_WEB_CHANGED=$(check_pattern "apps/storage/apps/web/|apps/storage/packages/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_AUTH_CHANGED" == "true" ] || [ "$SHARED_UI_CHANGED" == "true" ] || [ "$SHARED_WEB_CHANGED" == "true" ] || [ "$STORAGE_WEB_CHANGED" == "true" ]; then
|
|
echo "storage-web=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "storage-web=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# telegram-stats-bot
|
|
TELEGRAM_STATS_BOT_CHANGED=$(check_pattern "services/telegram-stats-bot/")
|
|
if [ "$COMMON_CHANGED" == "true" ] || [ "$TELEGRAM_STATS_BOT_CHANGED" == "true" ]; then
|
|
echo "telegram-stats-bot=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "telegram-stats-bot=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# Check if any service needs building
|
|
if grep -q "=true" $GITHUB_OUTPUT; then
|
|
echo "any-changes=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "any-changes=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Summary
|
|
run: |
|
|
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Service | Will Build |" >> $GITHUB_STEP_SUMMARY
|
|
echo "|---------|------------|" >> $GITHUB_STEP_SUMMARY
|
|
echo "| mana-core-auth | ${{ steps.changes.outputs.mana-core-auth }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| manacore-web | ${{ steps.changes.outputs.manacore-web }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| chat-backend | ${{ steps.changes.outputs.chat-backend }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| chat-web | ${{ steps.changes.outputs.chat-web }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| todo-backend | ${{ steps.changes.outputs.todo-backend }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| todo-web | ${{ steps.changes.outputs.todo-web }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| calendar-backend | ${{ steps.changes.outputs.calendar-backend }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| calendar-web | ${{ steps.changes.outputs.calendar-web }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| clock-backend | ${{ steps.changes.outputs.clock-backend }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| clock-web | ${{ steps.changes.outputs.clock-web }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| contacts-backend | ${{ steps.changes.outputs.contacts-backend }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| contacts-web | ${{ steps.changes.outputs.contacts-web }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| presi-backend | ${{ steps.changes.outputs.presi-backend }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| presi-web | ${{ steps.changes.outputs.presi-web }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| storage-backend | ${{ steps.changes.outputs.storage-backend }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| storage-web | ${{ steps.changes.outputs.storage-web }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| telegram-stats-bot | ${{ steps.changes.outputs.telegram-stats-bot }} |" >> $GITHUB_STEP_SUMMARY
|
|
|
|
# ===========================================
|
|
# Notify Build Start
|
|
# ===========================================
|
|
notify-start:
|
|
name: Notify Build Start
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.any-changes == 'true'
|
|
steps:
|
|
- name: Count services to build
|
|
id: count
|
|
run: |
|
|
COUNT=0
|
|
SERVICES=""
|
|
|
|
if [ "${{ needs.detect-changes.outputs.mana-core-auth }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• mana-core-auth\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.manacore-web }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• manacore-web\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.chat-backend }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• chat-backend\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.chat-web }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• chat-web\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.todo-backend }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• todo-backend\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.todo-web }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• todo-web\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.calendar-backend }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• calendar-backend\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.calendar-web }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• calendar-web\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.clock-backend }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• clock-backend\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.clock-web }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• clock-web\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.contacts-backend }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• contacts-backend\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.contacts-web }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• contacts-web\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.presi-backend }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• presi-backend\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.presi-web }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• presi-web\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.storage-backend }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• storage-backend\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.storage-web }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• storage-web\n"
|
|
fi
|
|
if [ "${{ needs.detect-changes.outputs.telegram-stats-bot }}" == "true" ]; then
|
|
COUNT=$((COUNT + 1))
|
|
SERVICES="${SERVICES}• telegram-stats-bot\n"
|
|
fi
|
|
|
|
# Estimate build time (roughly 3-5 min per service, parallel execution)
|
|
if [ $COUNT -le 3 ]; then
|
|
ESTIMATE="~3-5 min"
|
|
elif [ $COUNT -le 8 ]; then
|
|
ESTIMATE="~5-8 min"
|
|
else
|
|
ESTIMATE="~8-12 min"
|
|
fi
|
|
|
|
echo "count=$COUNT" >> $GITHUB_OUTPUT
|
|
echo "services<<EOF" >> $GITHUB_OUTPUT
|
|
echo -e "$SERVICES" >> $GITHUB_OUTPUT
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
echo "estimate=$ESTIMATE" >> $GITHUB_OUTPUT
|
|
|
|
- name: Send Telegram notification
|
|
env:
|
|
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
|
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
|
run: |
|
|
MESSAGE="🔨 *CI Build Started*
|
|
|
|
📦 *${{ steps.count.outputs.count }} services* building:
|
|
${{ steps.count.outputs.services }}
|
|
⏱️ Estimated: ${{ steps.count.outputs.estimate }}
|
|
🔗 [View Build](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
|
|
|
|
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
|
|
-d chat_id="${TELEGRAM_CHAT_ID}" \
|
|
-d text="${MESSAGE}" \
|
|
-d parse_mode="Markdown" \
|
|
-d disable_web_page_preview="true" || true
|
|
|
|
- name: Push build-started metrics to Prometheus
|
|
env:
|
|
PUSHGATEWAY_URL: ${{ secrets.PUSHGATEWAY_URL }}
|
|
run: |
|
|
# Skip if no Pushgateway URL configured
|
|
if [ -z "$PUSHGATEWAY_URL" ]; then
|
|
echo "PUSHGATEWAY_URL not configured, skipping metrics push"
|
|
exit 0
|
|
fi
|
|
|
|
START_EPOCH=$(date +%s)
|
|
|
|
# Push build-in-progress metric
|
|
cat <<EOF | curl --data-binary @- "${PUSHGATEWAY_URL}/metrics/job/ci/run_id/${{ github.run_id }}/branch/${{ github.ref_name }}"
|
|
# HELP ci_build_in_progress Whether a CI build is currently in progress
|
|
# TYPE ci_build_in_progress gauge
|
|
ci_build_in_progress 1
|
|
# HELP ci_build_start_timestamp_seconds Unix timestamp when build started
|
|
# TYPE ci_build_start_timestamp_seconds gauge
|
|
ci_build_start_timestamp_seconds ${START_EPOCH}
|
|
# HELP ci_build_services_count Number of services being built
|
|
# TYPE ci_build_services_count gauge
|
|
ci_build_services_count ${{ steps.count.outputs.count }}
|
|
EOF
|
|
|
|
echo "Build-started metrics pushed to Pushgateway"
|
|
|
|
# ===========================================
|
|
# Validation job - runs on PRs
|
|
# ===========================================
|
|
validate:
|
|
name: Validate
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request'
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: ${{ env.PNPM_VERSION }}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Validate monorepo best practices
|
|
run: pnpm run validate:monorepo
|
|
|
|
- name: Type check
|
|
run: pnpm run type-check
|
|
|
|
- name: Lint
|
|
run: pnpm run lint || echo "Lint warnings found"
|
|
|
|
# ===========================================
|
|
# Build Docker images - only changed services
|
|
# ===========================================
|
|
|
|
build-mana-core-auth:
|
|
name: Build mana-core-auth
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.mana-core-auth == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/mana-core-auth
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: services/mana-core-auth/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-manacore-web:
|
|
name: Build manacore-web
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.manacore-web == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/manacore-web
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/manacore/apps/web/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-chat-backend:
|
|
name: Build chat-backend
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.chat-backend == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/chat-backend
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/chat/apps/backend/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-chat-web:
|
|
name: Build chat-web
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.chat-web == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/chat-web
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/chat/apps/web/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-todo-backend:
|
|
name: Build todo-backend
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.todo-backend == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/todo-backend
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/todo/apps/backend/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-todo-web:
|
|
name: Build todo-web
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.todo-web == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/todo-web
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/todo/apps/web/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-calendar-backend:
|
|
name: Build calendar-backend
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.calendar-backend == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/calendar-backend
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/calendar/apps/backend/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-calendar-web:
|
|
name: Build calendar-web
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.calendar-web == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/calendar-web
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/calendar/apps/web/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-clock-backend:
|
|
name: Build clock-backend
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.clock-backend == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/clock-backend
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/clock/apps/backend/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-clock-web:
|
|
name: Build clock-web
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.clock-web == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/clock-web
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/clock/apps/web/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-contacts-backend:
|
|
name: Build contacts-backend
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.contacts-backend == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/contacts-backend
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/contacts/apps/backend/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-contacts-web:
|
|
name: Build contacts-web
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.contacts-web == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/contacts-web
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/contacts/apps/web/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-presi-backend:
|
|
name: Build presi-backend
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.presi-backend == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/presi-backend
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/presi/apps/backend/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-presi-web:
|
|
name: Build presi-web
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.presi-web == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/presi-web
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/presi/apps/web/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-storage-backend:
|
|
name: Build storage-backend
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.storage-backend == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/storage-backend
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/storage/apps/backend/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-storage-web:
|
|
name: Build storage-web
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.storage-web == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/storage-web
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: apps/storage/apps/web/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-telegram-stats-bot:
|
|
name: Build telegram-stats-bot
|
|
runs-on: ubuntu-latest
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.telegram-stats-bot == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/telegram-stats-bot
|
|
tags: type=raw,value=latest
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: services/telegram-stats-bot/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
# ===========================================
|
|
# Notify Build Complete
|
|
# ===========================================
|
|
notify-complete:
|
|
name: Notify Build Complete
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- detect-changes
|
|
- notify-start
|
|
- build-mana-core-auth
|
|
- build-manacore-web
|
|
- build-chat-backend
|
|
- build-chat-web
|
|
- build-todo-backend
|
|
- build-todo-web
|
|
- build-calendar-backend
|
|
- build-calendar-web
|
|
- build-clock-backend
|
|
- build-clock-web
|
|
- build-contacts-backend
|
|
- build-contacts-web
|
|
- build-presi-backend
|
|
- build-presi-web
|
|
- build-storage-backend
|
|
- build-storage-web
|
|
- build-telegram-stats-bot
|
|
if: always() && needs.detect-changes.outputs.any-changes == 'true'
|
|
steps:
|
|
- name: Calculate duration and status
|
|
id: result
|
|
run: |
|
|
# Get workflow start time from GitHub API
|
|
START_TIME="${{ github.event.repository.pushed_at }}"
|
|
|
|
# Calculate duration in minutes
|
|
START_EPOCH=$(date -d "${{ github.event.head_commit.timestamp }}" +%s 2>/dev/null || date +%s)
|
|
END_EPOCH=$(date +%s)
|
|
DURATION_SECONDS=$((END_EPOCH - START_EPOCH))
|
|
DURATION_MINUTES=$((DURATION_SECONDS / 60))
|
|
DURATION_REMAINDER=$((DURATION_SECONDS % 60))
|
|
|
|
echo "duration=${DURATION_MINUTES}m ${DURATION_REMAINDER}s" >> $GITHUB_OUTPUT
|
|
|
|
# Count successful and failed builds
|
|
SUCCESS=0
|
|
FAILED=0
|
|
SKIPPED=0
|
|
FAILED_SERVICES=""
|
|
SUCCESS_SERVICES=""
|
|
|
|
check_job() {
|
|
local job_name=$1
|
|
local result=$2
|
|
if [ "$result" == "success" ]; then
|
|
SUCCESS=$((SUCCESS + 1))
|
|
SUCCESS_SERVICES="${SUCCESS_SERVICES}✅ ${job_name}\n"
|
|
elif [ "$result" == "failure" ]; then
|
|
FAILED=$((FAILED + 1))
|
|
FAILED_SERVICES="${FAILED_SERVICES}❌ ${job_name}\n"
|
|
elif [ "$result" == "skipped" ]; then
|
|
SKIPPED=$((SKIPPED + 1))
|
|
fi
|
|
}
|
|
|
|
check_job "mana-core-auth" "${{ needs.build-mana-core-auth.result }}"
|
|
check_job "manacore-web" "${{ needs.build-manacore-web.result }}"
|
|
check_job "chat-backend" "${{ needs.build-chat-backend.result }}"
|
|
check_job "chat-web" "${{ needs.build-chat-web.result }}"
|
|
check_job "todo-backend" "${{ needs.build-todo-backend.result }}"
|
|
check_job "todo-web" "${{ needs.build-todo-web.result }}"
|
|
check_job "calendar-backend" "${{ needs.build-calendar-backend.result }}"
|
|
check_job "calendar-web" "${{ needs.build-calendar-web.result }}"
|
|
check_job "clock-backend" "${{ needs.build-clock-backend.result }}"
|
|
check_job "clock-web" "${{ needs.build-clock-web.result }}"
|
|
check_job "contacts-backend" "${{ needs.build-contacts-backend.result }}"
|
|
check_job "contacts-web" "${{ needs.build-contacts-web.result }}"
|
|
check_job "presi-backend" "${{ needs.build-presi-backend.result }}"
|
|
check_job "presi-web" "${{ needs.build-presi-web.result }}"
|
|
check_job "storage-backend" "${{ needs.build-storage-backend.result }}"
|
|
check_job "storage-web" "${{ needs.build-storage-web.result }}"
|
|
check_job "telegram-stats-bot" "${{ needs.build-telegram-stats-bot.result }}"
|
|
|
|
echo "success=$SUCCESS" >> $GITHUB_OUTPUT
|
|
echo "failed=$FAILED" >> $GITHUB_OUTPUT
|
|
|
|
if [ $FAILED -gt 0 ]; then
|
|
echo "status=❌ FAILED" >> $GITHUB_OUTPUT
|
|
echo "emoji=🔴" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "status=✅ SUCCESS" >> $GITHUB_OUTPUT
|
|
echo "emoji=🟢" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
echo "failed_services<<EOF" >> $GITHUB_OUTPUT
|
|
echo -e "$FAILED_SERVICES" >> $GITHUB_OUTPUT
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
|
|
- name: Send Telegram notification
|
|
env:
|
|
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
|
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
|
run: |
|
|
FAILED_INFO=""
|
|
if [ "${{ steps.result.outputs.failed }}" != "0" ]; then
|
|
FAILED_INFO="
|
|
❌ *Failed:*
|
|
${{ steps.result.outputs.failed_services }}"
|
|
fi
|
|
|
|
MESSAGE="${{ steps.result.outputs.emoji }} *CI Build Complete*
|
|
|
|
${{ steps.result.outputs.status }}
|
|
|
|
📊 *Results:*
|
|
✅ Success: ${{ steps.result.outputs.success }}
|
|
❌ Failed: ${{ steps.result.outputs.failed }}
|
|
|
|
⏱️ Duration: ${{ steps.result.outputs.duration }}
|
|
${FAILED_INFO}
|
|
🔗 [View Build](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
|
|
|
|
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
|
|
-d chat_id="${TELEGRAM_CHAT_ID}" \
|
|
-d text="${MESSAGE}" \
|
|
-d parse_mode="Markdown" \
|
|
-d disable_web_page_preview="true" || true
|
|
|
|
- name: Push metrics to Prometheus
|
|
if: always()
|
|
env:
|
|
PUSHGATEWAY_URL: ${{ secrets.PUSHGATEWAY_URL }}
|
|
run: |
|
|
# Skip if no Pushgateway URL configured
|
|
if [ -z "$PUSHGATEWAY_URL" ]; then
|
|
echo "PUSHGATEWAY_URL not configured, skipping metrics push"
|
|
exit 0
|
|
fi
|
|
|
|
# Calculate duration in seconds for metrics
|
|
START_EPOCH=$(date -d "${{ github.event.head_commit.timestamp }}" +%s 2>/dev/null || date +%s)
|
|
END_EPOCH=$(date +%s)
|
|
DURATION_SECONDS=$((END_EPOCH - START_EPOCH))
|
|
|
|
# Determine build status (1 = success, 0 = failed)
|
|
if [ "${{ steps.result.outputs.failed }}" == "0" ]; then
|
|
BUILD_STATUS=1
|
|
else
|
|
BUILD_STATUS=0
|
|
fi
|
|
|
|
# Push metrics to Pushgateway
|
|
cat <<EOF | curl --data-binary @- "${PUSHGATEWAY_URL}/metrics/job/ci/run_id/${{ github.run_id }}/branch/${{ github.ref_name }}"
|
|
# HELP ci_build_duration_seconds Duration of CI build in seconds
|
|
# TYPE ci_build_duration_seconds gauge
|
|
ci_build_duration_seconds ${DURATION_SECONDS}
|
|
# HELP ci_build_status Build status (1=success, 0=failed)
|
|
# TYPE ci_build_status gauge
|
|
ci_build_status ${BUILD_STATUS}
|
|
# HELP ci_builds_success_total Number of successful service builds
|
|
# TYPE ci_builds_success_total gauge
|
|
ci_builds_success_total ${{ steps.result.outputs.success }}
|
|
# HELP ci_builds_failed_total Number of failed service builds
|
|
# TYPE ci_builds_failed_total gauge
|
|
ci_builds_failed_total ${{ steps.result.outputs.failed }}
|
|
# HELP ci_build_timestamp_seconds Unix timestamp of build completion
|
|
# TYPE ci_build_timestamp_seconds gauge
|
|
ci_build_timestamp_seconds ${END_EPOCH}
|
|
# HELP ci_build_in_progress Whether a CI build is currently in progress
|
|
# TYPE ci_build_in_progress gauge
|
|
ci_build_in_progress 0
|
|
EOF
|
|
|
|
echo "Metrics pushed to Pushgateway successfully"
|