Files
homelab-infra/.gitea/workflows/ansible-deploy.yml
karpenok b2524d1d1e
ansible-deploy / plan (push) Successful in 2s
ansible-lint / lint (push) Successful in 3s
ansible-deploy / deploy (core-mon, ) (push) Successful in 17s
refactor(monitoring): split tasks into tagged subtasks, update BOOTSTRAP.md and .gitignore
2026-11-15 22:55:54 +07:00

87 lines
2.7 KiB
YAML

name: ansible-deploy
on:
push:
branches:
- main
paths:
- 'ansible/**'
paths-ignore:
- 'ansible/ci/**'
workflow_dispatch:
inputs:
machine:
description: 'Целевая машина (или all для полного прогона)'
required: true
default: 'all'
type: choice
options:
- all
- core-net
- core-secrets
- core-mon
- rus-central
- ger-nod-02
- opnsense
tags:
description: 'Необязательный фильтр тегов (например: remnawave, netbird, monitoring)'
required: false
default: ''
type: string
jobs:
plan:
runs-on: homelab
container:
image: homelab-ansible:latest
outputs:
matrix: ${{ steps.calc.outputs.matrix }}
has_targets: ${{ steps.calc.outputs.has_targets }}
steps:
- name: Вычислить затронутые машины
id: calc
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_BEFORE: ${{ github.event.before }}
EVENT_SHA: ${{ github.sha }}
INPUT_MACHINE: ${{ inputs.machine || 'all' }}
INPUT_TAGS: ${{ inputs.tags || '' }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
python3 "${HOME}/homelab-infra/ansible/ci/ansible-plan.py"
deploy:
needs: plan
if: needs.plan.outputs.has_targets == 'true'
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 45
strategy:
fail-fast: false
max-parallel: 1
matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
steps:
- name: Деплой ${{ matrix.machine }}
env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
chmod -R go-w "${HOME}/homelab-infra"
exec bash "${HOME}/homelab-infra/ansible/ci/deploy-machine.sh" \
"${{ matrix.machine }}" "${{ github.event_name }}" "${{ github.event.before }}" "${{ github.sha }}" "${{ matrix.tags }}"