Splitting Renovate workflows in two.
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
name: Check Renovate Updates
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
paths:
|
||||||
|
- 'docker-compose.yml'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ contains(toLower(github.event.pull_request.user.login), 'renovate') }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Validate docker-compose.yml
|
||||||
|
run: docker compose config
|
||||||
@@ -1,24 +1,35 @@
|
|||||||
name: Deploy Renovate Updates
|
name: Deploy Renovate Updates
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_run:
|
||||||
branches:
|
workflows: ["Check Renovate Updates"]
|
||||||
- main
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy Updated Services With Dependencies
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Only run if commit author name contains "renovate" (case-insensitive)
|
if: >
|
||||||
if: ${{ contains(toLower(github.event.head_commit.author.name), 'renovate') }}
|
${{
|
||||||
|
github.event.workflow_run.conclusion == 'success' &&
|
||||||
|
contains(toLower(github.event.workflow_run.head_commit.author.name), 'renovate')
|
||||||
|
}}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # we need full history to compute merge-base
|
||||||
|
|
||||||
- name: Set up Docker
|
- name: Set up Docker
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker (if needed)
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Install yq
|
- name: Install yq
|
||||||
run: |
|
run: |
|
||||||
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
|
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
|
||||||
@@ -29,15 +40,18 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "Finding modified services in docker-compose.yml..."
|
echo "Finding modified services in docker-compose.yml..."
|
||||||
|
|
||||||
# All services
|
# Find merge-base with previous main commit
|
||||||
ALL_SERVICES=$(yq e '.services | keys | .[]' docker-compose.yml)
|
BASE_COMMIT=$(git merge-base HEAD HEAD~1)
|
||||||
|
|
||||||
# Services changed in last commit
|
# Extract changed services between merge-base and HEAD
|
||||||
CHANGED_SERVICES=$(git diff --name-only HEAD~1 HEAD docker-compose.yml | xargs -I{} yq e '.services | keys | .[]' {})
|
CHANGED_SERVICES=$(git diff --name-only $BASE_COMMIT HEAD -- docker-compose.yml \
|
||||||
|
| xargs -r -I{} yq e '.services | keys | .[]' {})
|
||||||
|
|
||||||
echo "Changed services: $CHANGED_SERVICES"
|
if [ -z "$CHANGED_SERVICES" ]; then
|
||||||
|
echo "No services changed, skipping."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Recursively collect dependencies
|
|
||||||
declare -A VISITED
|
declare -A VISITED
|
||||||
ALL_DEPLOY=()
|
ALL_DEPLOY=()
|
||||||
|
|
||||||
Reference in New Issue
Block a user