fix: cicd ansible
Deploy bin / deploy (push) Successful in 6s
Deploy agebd python package / deploy (push) Successful in 2s

This commit is contained in:
Benjamin Labrecque
2026-07-07 18:02:13 +02:00
parent d9d11a6fe8
commit bfdc3cd238
@@ -1,31 +1,31 @@
name: Deploy, build and restart MASTER
# name: Deploy, build and restart MASTER
on:
push:
# TODO: if someone tags 'prod' to a (broken) feature branch
# this still triggers (and deploys to prod).
branches:
- main
tags:
- 'prod'
- 'v*'
# paths:
# - 'services/**'
# on:
# push:
# # TODO: if someone tags 'prod' to a (broken) feature branch
# # this still triggers (and deploys to prod).
# branches:
# - main
# tags:
# - 'prod'
# - 'v*'
# # paths:
# # - 'services/**'
jobs:
deploy:
runs-on: hla-dev
# jobs:
# deploy:
# runs-on: hla-dev
env:
# commit tagged ? yes->prod : no->dev
AGEBD_ENV: ${{ github.ref_type == 'tag' && 'prod' || 'dev' }}
SVC_CURRRENT_DIR: /sls/bd/hla/${{ github.ref_type == 'tag' && 'prod' || 'dev' }}/services/000-master/current
# env:
# # commit tagged ? yes->prod : no->dev
# AGEBD_ENV: ${{ github.ref_type == 'tag' && 'prod' || 'dev' }}
# SVC_CURRRENT_DIR: /sls/bd/hla/${{ github.ref_type == 'tag' && 'prod' || 'dev' }}/services/000-master/current
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for git diff tracking
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 0 # needed for git diff tracking
# - name: Copy files and replace {{ agebd_env }} with dev or prod
# run: |
@@ -46,28 +46,28 @@ jobs:
# systemctl --user enable --force ${SVC_CURRRENT_DIR}/systemd/AGEBD-SERVICE-MASTER.service
# systemctl --user restart AGEBD-SERVICE-MASTER.service
- name: Run Ansible Orchestrator
run: |
set -x
# - name: Run Ansible Orchestrator
# run: |
# set -x
# Disable pipefail temporarily or add an '|| true' fallback so grep doesn't kill the script
set +e
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
set -e
# # Disable pipefail temporarily or add an '|| true' fallback so grep doesn't kill the script
# set +e
# CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
# set -e
# 1. Parse changed directory names into space-separated string (e.g. "000-master 001-secondary")
CHANGED_SVC=$(echo "$CHANGED_FILES" | awk -F/ '$1=="services" {print $2}' | sort -u | xargs)
# # 1. Parse changed directory names into space-separated string (e.g. "000-master 001-secondary")
# CHANGED_SVC=$(echo "$CHANGED_FILES" | awk -F/ '$1=="services" {print $2}' | sort -u | xargs)
echo "Detected changed services: '$CHANGED_SVC'"
# echo "Detected changed services: '$CHANGED_SVC'"
# Safely halt the execution if there is nothing to pass to Ansible
if [ -z "$CHANGED_SVC" ]; then
echo "No services changed in this commit range. Skipping deployment smoothly."
exit 0
fi
# # Safely halt the execution if there is nothing to pass to Ansible
# if [ -z "$CHANGED_SVC" ]; then
# echo "No services changed in this commit range. Skipping deployment smoothly."
# exit 0
# fi
# 2. Figure out the destination target environment
ENV_TARGET="${{ github.ref_type == 'tag' && 'prod' || 'dev' }}"
# # 2. Figure out the destination target environment
# ENV_TARGET="${{ github.ref_type == 'tag' && 'prod' || 'dev' }}"
# 3. Fire the playbook passing variables down
ansible-playbook ansible/deploy-service.yml -e "changed_services_raw='$CHANGED_SVC' agebd_env='$ENV_TARGET'"
# # 3. Fire the playbook passing variables down
# ansible-playbook ansible/deploy-service.yml -e "changed_services_raw='$CHANGED_SVC' agebd_env='$ENV_TARGET'"