auto ansi?
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 0s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 0s
This commit is contained in:
@@ -1,27 +1,35 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Get the list of changed files
|
|
||||||
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
|
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
|
||||||
|
|
||||||
# Initialize an array for playbooks to run
|
|
||||||
PLAYBOOKS_TO_RUN=()
|
PLAYBOOKS_TO_RUN=()
|
||||||
|
PLAYBOOKS_TO_RUN_JUST_CREATED=()
|
||||||
|
|
||||||
# Check for changes in specific directories and add corresponding playbooks
|
# Check for changes in specific directories and add corresponding playbooks
|
||||||
if echo "$CHANGED_FILES" | grep -q "roles/webserver/"; then
|
if echo "$CHANGED_FILES" | grep -q "files/prometheus/"; then
|
||||||
PLAYBOOKS_TO_RUN+=("playbooks/webserver.yml")
|
PLAYBOOKS_TO_RUN+=("playbooks/software/prometheus.yml")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "$CHANGED_FILES" | grep -q "roles/database/"; then
|
if echo "$CHANGED_FILES" | grep -q "environments/just-created/"; then
|
||||||
PLAYBOOKS_TO_RUN+=("playbooks/database.yml")
|
PLAYBOOKS_TO_RUN_JUST_CREATED+=("playbooks/_common-setup.yml")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
PLAYBOOKS_TO_RUN2=( $(printf "%s\n" "${PLAYBOOKS_TO_RUN[@]}" | sort -u) )
|
||||||
|
|
||||||
# Run the identified playbooks
|
# Run the identified playbooks
|
||||||
if [ ${#PLAYBOOKS_TO_RUN[@]} -gt 0 ]; then
|
if [ ${#PLAYBOOKS_TO_RUN2[@]} -gt 0 ]; then
|
||||||
for playbook in "${PLAYBOOKS_TO_RUN[@]}"; do
|
for playbook in "${PLAYBOOKS_TO_RUN2[@]}"; do
|
||||||
echo "Running playbook: $playbook"
|
echo "Running playbook: $playbook"
|
||||||
ansible-playbook "$playbook" -i inventory.ini
|
ansible-playbook "$playbook" -i environments/proxmoxes/hosts.yml
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ${#PLAYBOOKS_TO_RUN_JUST_CREATED[@]} -gt 0 ]; then
|
||||||
|
for playbook in "${PLAYBOOKS_TO_RUN_JUST_CREATED[@]}"; do
|
||||||
|
echo "Running playbook: $playbook"
|
||||||
|
ansible-playbook "$playbook" -i environments/just-created/hosts.yml
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "No relevant playbooks modified. Skipping Ansible run."
|
echo "No relevant playbooks modified. Skipping Ansible run."
|
||||||
fi
|
fi
|
||||||
shell: bash
|
|
||||||
Reference in New Issue
Block a user