diff --git a/.forgejo/workflows/CD.yml b/.forgejo/workflows/CD.yml index 9db2271..71bc745 100644 --- a/.forgejo/workflows/CD.yml +++ b/.forgejo/workflows/CD.yml @@ -36,71 +36,82 @@ jobs: shell: bash run: | IFS=' ' read -r -a folder_array <<< "${{ steps.detect-changes.outputs.folders }}" + hosts="" + folders="" + for folder in "${folder_array[@]}"; do case $folder in actual) - target_host="ubu.lan" + host="ubu.lan" ;; arrs) - target_host="arrs.lan" + host="arrs.lan" ;; arm) - target_host="arm.lan" + host="arm.lan" ;; AI) - target_host="ai.lan" + host="ai.lan" ;; authentik) - target_host="auth.lan" + host="auth.lan" ;; ag-main) - target_host="dns.lan" + host="dns.lan" ;; exporters) - target_host="all" + host="all" ;; grafana) - target_host="ubu.lan" + host="ubu.lan" ;; jellyfin) - target_host="jf.lan" + host="jf.lan" ;; kasm) - target_host="kasm.lan" + host="kasm.lan" ;; netboot) - target_host="netboot.lan" + host="netboot.lan" ;; nexterm) - target_host="ubu.lan" + host="ubu.lan" ;; npm) - target_host="npm.lan" + host="npm.lan" ;; plex) - target_host="plex.lan" + host="plex.lan" ;; paperless) - target_host="ubu.lan" + host="ubu.lan" ;; portainer) - target_host="port.lan" + host="port.lan" ;; runner) - target_host="runner.lan" + host="runner.lan" ;; - # Add cases for other folders/hosts *) echo "Unknown folder: $folder" exit 1 ;; esac - echo "Deploying to $target_host for folder $folder" - echo "target_host=$target_host" >> $GITHUB_ENV - echo "folder=$folder" >> $GITHUB_ENV + if [ -z "$hosts" ]; then + hosts="$host" + folders="$folder" + else + hosts="$hosts,$host" + folders="$folders,$folder" + fi done + echo "Deploying to hosts: $hosts for folders: $folders" + + echo "target_host=$hosts" >> $GITHUB_ENV + echo "folder=$folders" >> $GITHUB_ENV + - name: Get Secrets from Bitwarden id: bitwarden-secrets uses: https://github.com/bitwarden/sm-action@v2 diff --git a/ansible/playbooks/deploy-docker.yml b/ansible/playbooks/deploy-docker.yml index 19d667e..95d61cc 100644 --- a/ansible/playbooks/deploy-docker.yml +++ b/ansible/playbooks/deploy-docker.yml @@ -1,7 +1,7 @@ - name: Deploy application - hosts: "{{ target_host }}" + hosts: "{{ target_host.split(',') | join(',') }}" vars: - repo_path: "/home/{{ ansible_user }}/iac/docker/{{ folder }}" + repo_path: "/home/{{ ansible_user }}/iac/docker/{{ folder.split(',') | join(',') }}" secrets_mapping_file: "/home/{{ ansible_user }}/iac/docker/secret-mappings.yml" tasks: - name: Ensure the repository is up-to-date