e3d5d792af
Deploy Renovate Updates / Deploy Updated Services With Dependencies (push) Failing after 14m21s
85 lines
2.6 KiB
YAML
85 lines
2.6 KiB
YAML
name: Deploy Renovate Updates
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Deploy Updated Services With Dependencies
|
|
runs-on: ubuntu-latest
|
|
# Only run if commit author name contains "renovate" (case-insensitive)
|
|
if: ${{ contains(toLower(github.event.head_commit.author.name), 'renovate') }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Install yq
|
|
run: |
|
|
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
|
|
sudo chmod +x /usr/bin/yq
|
|
|
|
- name: Get modified services including dependencies
|
|
id: modified_services
|
|
run: |
|
|
echo "Finding modified services in docker-compose.yml..."
|
|
|
|
# All services
|
|
ALL_SERVICES=$(yq e '.services | keys | .[]' docker-compose.yml)
|
|
|
|
# Services changed in last commit
|
|
CHANGED_SERVICES=$(git diff --name-only HEAD~1 HEAD docker-compose.yml | xargs -I{} yq e '.services | keys | .[]' {})
|
|
|
|
echo "Changed services: $CHANGED_SERVICES"
|
|
|
|
# Recursively collect dependencies
|
|
declare -A VISITED
|
|
ALL_DEPLOY=()
|
|
|
|
get_deps() {
|
|
local service=$1
|
|
if [[ -n "${VISITED[$service]}" ]]; then
|
|
return
|
|
fi
|
|
VISITED[$service]=1
|
|
ALL_DEPLOY+=("$service")
|
|
|
|
# Array style depends_on
|
|
deps=$(yq e ".services.\"$service\".depends_on[]?" docker-compose.yml 2>/dev/null)
|
|
for dep in $deps; do
|
|
get_deps "$dep"
|
|
done
|
|
|
|
# Mapping style depends_on (with condition)
|
|
deps_map=$(yq e ".services.\"$service\".depends_on | keys[]" docker-compose.yml 2>/dev/null)
|
|
for dep in $deps_map; do
|
|
get_deps "$dep"
|
|
done
|
|
}
|
|
|
|
for svc in $CHANGED_SERVICES; do
|
|
get_deps "$svc"
|
|
done
|
|
|
|
echo "Services to deploy: ${ALL_DEPLOY[@]}"
|
|
echo "modified_services=${ALL_DEPLOY[@]}" >> $GITHUB_ENV
|
|
|
|
- name: Pull images for modified services
|
|
if: env.modified_services != ''
|
|
run: |
|
|
echo "Pulling images for services: $modified_services"
|
|
for svc in $modified_services; do
|
|
docker compose pull $svc || echo "Failed to pull $svc, continuing..."
|
|
done
|
|
|
|
- name: Deploy updated services
|
|
if: env.modified_services != ''
|
|
run: |
|
|
echo "Deploying services: $modified_services"
|
|
docker compose up -d $modified_services
|