Files
hla_framework_bd/.gitea/workflows/deploy.yml
T
2026-07-30 14:21:16 +02:00

113 lines
3.3 KiB
YAML

name: Deploy
on:
push:
branches:
- main
tags:
- 'prod'
- 'v*'
paths:
- 'bin/**'
- 'packages/agebd/**'
- 'qt/**'
- 'services/**'
# Cancel previous runs if a new commit is pushed to the same branch
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
env:
# commit tagged ? yes->prod : no->dev
AGEBD_ENV: ${{ github.ref_type == 'tag' && 'prod' || 'dev' }}
jobs:
deploy:
runs-on: hla-dev
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for git diff in service detection
- name: Define filter paths
uses: actions/paths-filter@v3
id: filter
with:
filters: |
bin:
- 'bin/**'
agebd:
- 'packages/agebd/**'
qt:
- 'qt/**'
services:
- 'services/**'
- name: Install uv
uses: actions/setup-uv@v5
- name: Install Python 3.10
run: uv python install 3.10
- name: Run tests
run: |
UV_CACHE_DIR="/sls/bd/hla/.cache/uv"
uv run --directory cli pytest
uv run --directory packages/agebd pytest
uv run --directory scripts pytest
# -----------------------------------------------------------------
# Directory Deployments
# -----------------------------------------------------------------
- name: Bin - deploy
if: steps.filter.outputs.bin == 'true'
env:
DEST_DIR: /sls/bd/hla/${{ env.AGEBD_ENV }}/bin
run: |
mkdir -p "${DEST_DIR}"
rsync -av --delete --exclude='.nfs*' ./bin/ "${DEST_DIR}/"
- name: Agebd - deploy
if: steps.filter.outputs.agebd == 'true'
env:
DEST_DIR: /sls/bd/hla/${{ env.AGEBD_ENV }}/packages/agebd
run: |
mkdir -p "${DEST_DIR}"
rsync -av --delete --exclude='.nfs*' ./packages/agebd/ "${DEST_DIR}/"
- name: Qt - deploy
if: steps.filter.outputs.qt == 'true'
env:
DEST_DIR: /sls/bd/hla/${{ env.AGEBD_ENV }}/qt
run: |
mkdir -p "${DEST_DIR}"
rsync -av --delete --exclude='.nfs*' ./qt/ "${DEST_DIR}/"
# -----------------------------------------------------------------
# Services Deployment
# -----------------------------------------------------------------
- name: Deploy Changed Services
if: steps.filter.outputs.services == 'true'
run: |
# 1. Determine git comparison point
BEFORE="${{ github.event.before }}"
if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
BEFORE="HEAD~1"
fi
# 2. Extract list of modified service folder names
CHANGED_SERVICES=$(git diff --name-only "$BEFORE" "${{ github.sha }}" | awk -F/ '$1=="services" && $2!="" {print $2}' | sort -u)
if [ -z "$CHANGED_SERVICES" ]; then
echo "No service directory changes detected in diff."
exit 0
fi
# 3. Loop through changed services and invoke deployment script
echo "$CHANGED_SERVICES" | while read -r SERVICE; do
./.gitea/scripts/deploy-and-restart-service.sh "${SERVICE}" "${AGEBD_ENV}"
done