170 lines
5.1 KiB
YAML
170 lines
5.1 KiB
YAML
name: renovate
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: "@hourly"
|
|
push:
|
|
|
|
jobs:
|
|
discover-repos:
|
|
name: Discover Repositories
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
repo-batches: ${{ steps.create-batches.outputs.batches }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Renovate
|
|
uses: renovatebot/github-action@v39.221.0
|
|
with:
|
|
configurationFile: config.js
|
|
token: ${{ secrets.RENOVATE_TOKEN }}
|
|
|
|
- name: Discover Repositories
|
|
run: |
|
|
renovate --write-discovered-repos=renovate-repos.json
|
|
env:
|
|
RENOVATE_CONFIG_FILE: "config.js"
|
|
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
|
|
GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
LOG_LEVEL: "info"
|
|
RENOVATE_AUTODISCOVER: "true"
|
|
|
|
- name: Create Repository Batches
|
|
id: create-batches
|
|
shell: bash
|
|
run: |
|
|
if [ ! -f renovate-repos.json ] || [ ! -s renovate-repos.json ]; then
|
|
echo "No repositories discovered or file not created"
|
|
echo "batches=[]" >> $GITHUB_OUTPUT
|
|
exit 0
|
|
fi
|
|
|
|
# Read repositories and create batches of 5
|
|
REPOS=$(cat renovate-repos.json)
|
|
|
|
# Use Python (available in GitHub Actions runner) for JSON processing
|
|
BATCHES=$(python3 -c '
|
|
import json
|
|
import sys
|
|
|
|
try:
|
|
data = json.loads(sys.argv[1])
|
|
if not isinstance(data, list):
|
|
print("[]")
|
|
sys.exit(0)
|
|
|
|
# Create batches of 5
|
|
batches = []
|
|
for i in range(0, len(data), 5):
|
|
batches.append(data[i:i+5])
|
|
|
|
print(json.dumps(batches))
|
|
except Exception as e:
|
|
print(f"Error: {e}", file=sys.stderr)
|
|
print("[]")
|
|
' "$REPOS")
|
|
|
|
echo "Created batches: $BATCHES"
|
|
echo "batches=$BATCHES" >> $GITHUB_OUTPUT
|
|
|
|
renovate:
|
|
name: Run Renovate
|
|
needs: discover-repos
|
|
runs-on: ubuntu-latest
|
|
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: Setup Renovate
|
|
uses: renovatebot/github-action@v39.221.0
|
|
with:
|
|
configurationFile: config.js
|
|
token: ${{ secrets.RENOVATE_TOKEN }}
|
|
|
|
- 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: Run Renovate on Batch
|
|
shell: bash
|
|
run: |
|
|
# Simple approach to create comma-separated list
|
|
REPOS=""
|
|
# Make sure batch is not empty
|
|
if [ -n "$BATCH" ] && [ "$BATCH" != "null" ]; then
|
|
# Convert JSON array to comma-separated string
|
|
REPOS=$(python3 -c '
|
|
import json
|
|
import sys
|
|
|
|
try:
|
|
batch = json.loads(sys.argv[1])
|
|
if isinstance(batch, list) and batch:
|
|
print(",".join(batch))
|
|
except Exception as e:
|
|
print(f"Error: {e}", file=sys.stderr)
|
|
' "$BATCH")
|
|
fi
|
|
|
|
if [ -n "$REPOS" ]; then
|
|
echo "Processing repositories: $REPOS"
|
|
renovate $REPOS
|
|
else
|
|
echo "No repositories to process in this batch"
|
|
fi
|
|
env:
|
|
BATCH: ${{ toJson(matrix.batch) }}
|
|
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-default:
|
|
name: Run Renovate (Default)
|
|
needs: discover-repos
|
|
runs-on: ubuntu-latest
|
|
if: ${{ needs.discover-repos.outputs.repo-batches == '[]' }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Renovate
|
|
uses: renovatebot/github-action@v39.221.0
|
|
with:
|
|
configurationFile: config.js
|
|
token: ${{ secrets.RENOVATE_TOKEN }}
|
|
|
|
- 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
|