renovate-runner/.gitea/workflows/renovate.yaml
jank 576722b60e
Some checks failed
renovate / Discover Repositories (push) Failing after 6s
renovate / Run Renovate (push) Has been skipped
renovate / Run Renovate (Default) (push) Has been skipped
Update .gitea/workflows/renovate.yaml
2025-03-27 17:07:59 +00:00

162 lines
5.3 KiB
YAML

name: renovate
on:
workflow_dispatch:
schedule:
- cron: "@hourly"
push:
jobs:
discover-repos:
name: Discover Repositories
runs-on: ubuntu-latest
container: ghcr.io/renovatebot/renovate:39.219.2
outputs:
repo-batches: ${{ steps.create-batches.outputs.batches }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Renovate dependencies
uses: actions/cache@v4
with:
path: /tmp/renovate-cache
key: ${{ runner.os }}-renovate-discovery-${{ hashFiles('config.js') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-renovate-discovery-${{ hashFiles('config.js') }}-
${{ runner.os }}-renovate-discovery-
- name: Install jq
run: |
apt-get update && apt-get install -y jq
- name: Discover Repositories
run: |
renovate --write-discovered-repos=/tmp/renovate-repos.json
env:
RENOVATE_CONFIG_FILE: "config.js"
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }}
LOG_LEVEL: "info"
RENOVATE_CACHE_DIR: /tmp/renovate-cache
RENOVATE_AUTODISCOVER: "true"
- name: Create Repository Batches
id: create-batches
run: |
# Check if repos file exists and is not empty
if [ ! -f /tmp/renovate-repos.json ] || [ ! -s /tmp/renovate-repos.json ]; then
echo "No repositories discovered or file not created/empty"
echo "batches=[]" >> $GITHUB_OUTPUT
exit 0
fi
# Verify the file contains valid JSON
if ! jq empty /tmp/renovate-repos.json 2>/dev/null; then
echo "Invalid JSON in repositories file"
echo "batches=[]" >> $GITHUB_OUTPUT
exit 0
fi
# Read the JSON array and create batches
echo "Creating batches of repositories..."
batches=$(jq -c 'if type == "array" then . else [] end | _nwise(5) | [.[]]' /tmp/renovate-repos.json)
# Handle empty results
if [ "$batches" = "" ] || [ "$batches" = "null" ]; then
echo "No valid repositories found"
echo "batches=[]" >> $GITHUB_OUTPUT
exit 0
fi
# Format as proper JSON array for GitHub Actions output
batches="[$(echo "$batches" | tr '\n' ',' | sed 's/,$//' )]"
echo "batches=$batches" >> $GITHUB_OUTPUT
echo "Created $(echo "$batches" | jq '. | length') batches of repositories"
renovate:
name: Run Renovate
needs: discover-repos
runs-on: ubuntu-latest
container: ghcr.io/renovatebot/renovate:39.219.2
if: ${{ needs.discover-repos.outputs.repo-batches != '[]' }}
strategy:
matrix:
batch: ${{ fromJson(needs.discover-repos.outputs.repo-batches) }}
fail-fast: false
max-parallel: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Renovate dependencies
uses: actions/cache@v4
with:
path: /tmp/renovate-cache
key: ${{ runner.os }}-renovate-batch-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-renovate-
- name: Install jq
run: |
apt-get update && apt-get install -y jq
- name: Run Renovate on Batch
run: |
# Simple processing of batch array without complex jq
REPOS=""
for repo in $(echo '${{ toJson(matrix.batch) }}' | jq -r '.[]'); do
if [ -n "$REPOS" ]; then
REPOS="$REPOS,$repo"
else
REPOS="$repo"
fi
done
echo "Processing repositories: $REPOS"
# Run Renovate on the specific repositories
if [ -n "$REPOS" ]; then
renovate $REPOS
else
echo "No repositories to process in this batch"
fi
env:
RENOVATE_CONFIG_FILE: "config.js"
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }}
LOG_LEVEL: "info"
RENOVATE_CACHE_DIR: /tmp/renovate-cache
# Fallback job in case no repositories are found or for handling config repositories
renovate-default:
name: Run Renovate (Default)
needs: discover-repos
runs-on: ubuntu-latest
container: ghcr.io/renovatebot/renovate:39.219.2
if: ${{ needs.discover-repos.outputs.repo-batches == '[]' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Renovate dependencies
uses: actions/cache@v4
with:
path: /tmp/renovate-cache
key: ${{ runner.os }}-renovate-default-${{ hashFiles('config.js') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-renovate-default-${{ hashFiles('config.js') }}-
${{ runner.os }}-renovate-default-
- name: Run Renovate
run: renovate
env:
RENOVATE_CONFIG_FILE: "config.js"
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }}
LOG_LEVEL: "info"
RENOVATE_CACHE_DIR: /tmp/renovate-cache