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 }}"