Update .gitea/workflows/renovate.yaml
Some checks failed
renovate / discover (push) Successful in 32s
renovate / renovate (push) Failing after 13s

This commit is contained in:
Jan K9f 2025-03-27 14:42:57 +00:00
parent 6f14bb6b4b
commit 806e96043b

View file

@ -6,42 +6,149 @@ on:
- cron: "@hourly"
push:
env:
# Define Gitea endpoint once
GITEA_ENDPOINT: https://git.kjan.de/api/v1
# Define the number of parallel jobs you want
RENOVATE_PARALLEL_JOBS: 4
jobs:
renovate:
# ----------------------------------------------------
# Job 1: Discover repositories via Gitea API
# ----------------------------------------------------
discover:
runs-on: ubuntu-latest
# Pin to a specific Renovate version for stability (check ghcr.io for latest)
# Example: ghcr.io/renovatebot/renovate:37.250.0
container: ghcr.io/renovatebot/renovate:39.219.2 # Pinned version
outputs:
# Output the list of repositories as a JSON string
repositories: ${{ steps.get_repos.outputs.repositories }}
steps:
- name: Install curl and jq
run: sudo apt-get update && sudo apt-get install -y curl jq
- name: Get Repositories from Gitea
id: get_repos
env:
GITEA_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
run: |
set -e # Exit on error
all_repos="[]"
page=1
limit=50 # Repos per page
echo "Fetching repositories from ${{ env.GITEA_ENDPOINT }}"
while true; do
# Fetch a page of repositories (adjust endpoint if needed, e.g., /orgs/{org}/repos)
# This assumes the token has access via /user/repos
response=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"${{ env.GITEA_ENDPOINT }}/user/repos?limit=$limit&page=$page")
# Check if the response is a valid JSON array
if ! echo "$response" | jq -e 'type == "array"' > /dev/null; then
echo "Error: Invalid response from Gitea API (Page $page):"
echo "$response"
exit 1
fi
count=$(echo "$response" | jq 'length')
echo "Fetched $count repositories on page $page."
if [ "$count" -eq 0 ]; then
break # No more repositories
fi
# Filter for non-archived repos and extract full_name, merge with previous results
page_repos=$(echo "$response" | jq '[.[] | select(.archived == false) | .full_name]')
all_repos=$(jq -n --argjson current "$all_repos" --argjson new "$page_repos" '$current + $new')
if [ "$count" -lt "$limit" ]; then
break # Last page reached
fi
page=$((page + 1))
done
repo_count=$(echo "$all_repos" | jq 'length')
echo "Total non-archived repositories found: $repo_count"
# Output the list as a compact JSON string array
echo "repositories=$(echo "$all_repos" | jq -c .)" >> $GITHUB_OUTPUT
# ----------------------------------------------------
# Job 2: Run Renovate in Parallel using Matrix
# ----------------------------------------------------
renovate:
needs: discover # Run after discovery is complete
runs-on: ubuntu-latest
# Pin to a specific Renovate version
container: ghcr.io/renovatebot/renovate:37.290.1
strategy:
fail-fast: false # Prevent other jobs from stopping if one fails
matrix:
# Create a matrix based on the desired number of parallel jobs
partition: ${{ fromJson(format('[{0}]', join(range(0, env.RENOVATE_PARALLEL_JOBS), ','))) }}
steps:
# Checkout the repository containing config.js
- name: Checkout
# Checkout the repository containing base config.js (if needed for extends)
- name: Checkout Base Config Repo
uses: actions/checkout@v4
# Cache Renovate's dependency cache directory between runs
# Shared cache key across matrix jobs - Renovate should handle internal locking
- name: Cache Renovate dependencies
uses: actions/cache@v4
with:
path: /tmp/renovate-cache # Renovate's default cache directory
# Key based on OS, config file hash, and run ID (ensures save)
key: ${{ runner.os }}-renovate-${{ hashFiles('config.js') }}-${{ github.run_id }}
# Fallback keys for restoring from previous runs
restore-keys: |
${{ runner.os }}-renovate-${{ hashFiles('config.js') }}-
${{ runner.os }}-renovate-
# Run Renovate using the configuration file
- name: Run Renovate
- name: Generate Partitioned Config
id: generate_config
run: |
set -e
# Get the full list of repos from the discover job output
ALL_REPOS_JSON='${{ needs.discover.outputs.repositories }}'
# Get the current job index and total number of jobs
JOB_INDEX=${{ matrix.partition }}
TOTAL_JOBS=${{ env.RENOVATE_PARALLEL_JOBS }}
echo "Generating config for partition $JOB_INDEX / $TOTAL_JOBS"
# Use jq to filter the repository list for this specific partition
# Selects repositories where (repo_index % total_jobs) == current_job_index
PARTITION_REPOS_JSON=$(echo "$ALL_REPOS_JSON" | jq --argjson idx "$JOB_INDEX" --argjson total "$TOTAL_JOBS" \
'[.[range(length) | select(. % $total == $idx)]]')
PARTITION_REPO_COUNT=$(echo "$PARTITION_REPOS_JSON" | jq 'length')
echo "Repositories in this partition: $PARTITION_REPO_COUNT"
# echo "$PARTITION_REPOS_JSON" # Uncomment for debugging
# Create a temporary JSON config file for this Renovate run
# It includes the base settings from config.js but overrides/sets 'repositories'
# and removes 'autodiscover'
jq --argjson repos "$PARTITION_REPOS_JSON" \
'.repositories = $repos | del(.autodiscover) | del(.onboardingConfig)' \
config.js > renovate-partition-${JOB_INDEX}.json
echo "Generated config file: renovate-partition-${JOB_INDEX}.json"
# Store filename for the next step
echo "config_file=renovate-partition-${JOB_INDEX}.json" >> $GITHUB_OUTPUT
# Run Renovate using the generated partitioned configuration file
- name: Run Renovate Partition ${{ matrix.partition }}
run: renovate
env:
# --- Core Configuration ---
RENOVATE_CONFIG_FILE: "config.js" # Path to your config file
# Use the generated JSON config file for this partition
RENOVATE_CONFIG_FILE: ${{ steps.generate_config.outputs.config_file }}
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} # Token for Gitea
GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }} # Only needed if Renovate MUST access github.com (e.g., for release notes). Remove if not needed.
GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }} # Only if needed
# --- Performance & Logging ---
# Use 'info' for normal runs, 'debug' only when troubleshooting
LOG_LEVEL: "info"
# Explicitly tell Renovate where the cache is (matches actions/cache path)
LOG_LEVEL: "info" # Use 'debug' only when troubleshooting
RENOVATE_CACHE_DIR: /tmp/renovate-cache
# Optional: Lower concurrency per job if needed, depends on runner resources
# RENOVATE_CONCURRENCY: 5