Skip to content

Commit e54adf5

Browse files
committedFeb 14, 2025
test fix cd multiple hosts
1 parent 41d91e3 commit e54adf5

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed
 

‎.forgejo/workflows/CD.yml

+32-21
Original file line numberDiff line numberDiff line change
@@ -36,71 +36,82 @@ jobs:
3636
shell: bash
3737
run: |
3838
IFS=' ' read -r -a folder_array <<< "${{ steps.detect-changes.outputs.folders }}"
39+
hosts=""
40+
folders=""
41+
3942
for folder in "${folder_array[@]}"; do
4043
case $folder in
4144
actual)
42-
target_host="ubu.lan"
45+
host="ubu.lan"
4346
;;
4447
arrs)
45-
target_host="arrs.lan"
48+
host="arrs.lan"
4649
;;
4750
arm)
48-
target_host="arm.lan"
51+
host="arm.lan"
4952
;;
5053
AI)
51-
target_host="ai.lan"
54+
host="ai.lan"
5255
;;
5356
authentik)
54-
target_host="auth.lan"
57+
host="auth.lan"
5558
;;
5659
ag-main)
57-
target_host="dns.lan"
60+
host="dns.lan"
5861
;;
5962
exporters)
60-
target_host="all"
63+
host="all"
6164
;;
6265
grafana)
63-
target_host="ubu.lan"
66+
host="ubu.lan"
6467
;;
6568
jellyfin)
66-
target_host="jf.lan"
69+
host="jf.lan"
6770
;;
6871
kasm)
69-
target_host="kasm.lan"
72+
host="kasm.lan"
7073
;;
7174
netboot)
72-
target_host="netboot.lan"
75+
host="netboot.lan"
7376
;;
7477
nexterm)
75-
target_host="ubu.lan"
78+
host="ubu.lan"
7679
;;
7780
npm)
78-
target_host="npm.lan"
81+
host="npm.lan"
7982
;;
8083
plex)
81-
target_host="plex.lan"
84+
host="plex.lan"
8285
;;
8386
paperless)
84-
target_host="ubu.lan"
87+
host="ubu.lan"
8588
;;
8689
portainer)
87-
target_host="port.lan"
90+
host="port.lan"
8891
;;
8992
runner)
90-
target_host="runner.lan"
93+
host="runner.lan"
9194
;;
92-
# Add cases for other folders/hosts
9395
*)
9496
echo "Unknown folder: $folder"
9597
exit 1
9698
;;
9799
esac
98-
echo "Deploying to $target_host for folder $folder"
99100
100-
echo "target_host=$target_host" >> $GITHUB_ENV
101-
echo "folder=$folder" >> $GITHUB_ENV
101+
if [ -z "$hosts" ]; then
102+
hosts="$host"
103+
folders="$folder"
104+
else
105+
hosts="$hosts,$host"
106+
folders="$folders,$folder"
107+
fi
102108
done
103109
110+
echo "Deploying to hosts: $hosts for folders: $folders"
111+
112+
echo "target_host=$hosts" >> $GITHUB_ENV
113+
echo "folder=$folders" >> $GITHUB_ENV
114+
104115
- name: Get Secrets from Bitwarden
105116
id: bitwarden-secrets
106117
uses: https://github.com/bitwarden/sm-action@v2

‎ansible/playbooks/deploy-docker.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
- name: Deploy application
2-
hosts: "{{ target_host }}"
2+
hosts: "{{ target_host.split(',') | join(',') }}"
33
vars:
4-
repo_path: "/home/{{ ansible_user }}/iac/docker/{{ folder }}"
4+
repo_path: "/home/{{ ansible_user }}/iac/docker/{{ folder.split(',') | join(',') }}"
55
secrets_mapping_file: "/home/{{ ansible_user }}/iac/docker/secret-mappings.yml"
66
tasks:
77
- name: Ensure the repository is up-to-date

0 commit comments

Comments
 (0)
Please sign in to comment.