Adding separate workflow for Renovate PRs.
Deploy Renovate Updates / Deploy Updated Services With Dependencies (push) Failing after 1m52s
Deploy Renovate Updates / Deploy Updated Services With Dependencies (push) Failing after 1m52s
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
name: Deploy Renovate Updates
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy Updated Services With Dependencies
|
||||
runs-on: ubuntu-latest
|
||||
if: contains(github.event.head_commit.message, '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, handling both array and mapping style
|
||||
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
|
||||
Reference in New Issue
Block a user