Files
homelab-infra/.gitea/workflows/netbird-install.yml
T

66 lines
2.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: netbird-install
on:
workflow_dispatch:
inputs:
letsencrypt_email:
description: Почта для уведомлений Let's Encrypt (по умолчанию из group_vars/all.yml)
required: false
type: string
default: 'vvkarpenok@gmail.com'
jobs:
install:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 30
steps:
- name: Запустить плейбук NetBird
env:
RUNNER_SSH_KEY: ${{ secrets.RUNNER_SSH_KEY }}
BW_CLIENTID: ${{ secrets.BW_CLIENTID }}
BW_CLIENTSECRET: ${{ secrets.BW_CLIENTSECRET }}
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
NETBIRD_LETSENCRYPT_EMAIL: ${{ inputs.letsencrypt_email }}
run: |
set -eu
if [ -z "${RUNNER_SSH_KEY}" ]; then
echo "В секретах нет RUNNER_SSH_KEY." >&2
exit 1
fi
# Настройка и вход в Bitwarden CLI для получения секретов на лету
bw config server https://pass.gunihome.ru
export BW_CLIENTID="${BW_CLIENTID}"
export BW_CLIENTSECRET="${BW_CLIENTSECRET}"
bw login --apikey
export BW_SESSION=$(bw unlock --passwordenv BW_PASSWORD --raw)
trap 'rm -f "${HOME}/.ssh/id_ed25519"; bw lock 2>/dev/null || true' EXIT
rm -rf "${HOME}/homelab-infra"
git clone https://gitea.gunihome.ru/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"
install -d -m 700 "${HOME}/.ssh"
printf '%s\n' "${RUNNER_SSH_KEY}" > "${HOME}/.ssh/id_ed25519"
chmod 600 "${HOME}/.ssh/id_ed25519"
cd "${HOME}/homelab-infra"
extra_args=()
if [ -n "${NETBIRD_LETSENCRYPT_EMAIL:-}" ]; then
extra_args+=("-e" "netbird_letsencrypt_email=${NETBIRD_LETSENCRYPT_EMAIL}")
fi
ansible-playbook playbooks/site.yml \
-i inventories/prod/hosts.yml \
--limit netbird \
--private-key "${HOME}/.ssh/id_ed25519" \
"${extra_args[@]}"