Update .gitea/workflows/renovate.yaml
All checks were successful
renovate / Discover Repositories (push) Successful in 1m6s
renovate / Run Renovate (Default) (push) Has been skipped
renovate / Run Renovate (push) Successful in 41s

This commit is contained in:
Jan K9f 2025-03-27 17:12:04 +00:00
parent ab242fb0e6
commit 2b469d47c3

View file

@ -17,11 +17,9 @@ jobs:
- 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: Install Renovate
run: |
npm install -g renovate
- name: Discover Repositories
run: |
@ -35,7 +33,6 @@ jobs:
- 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"
@ -43,33 +40,54 @@ jobs:
exit 0
fi
# Read repositories and create batches of 5
REPOS=$(cat renovate-repos.json)
# Install jq if not available
if ! command -v jq &> /dev/null; then
sudo apt-get update && sudo apt-get install -y jq
fi
# Use Python (available in GitHub Actions runner) for JSON processing
BATCHES=$(python3 -c '
import json
import sys
# Check if file contains valid JSON
if ! jq . renovate-repos.json > /dev/null 2>&1; then
echo "File does not contain valid JSON"
echo "batches=[]" >> $GITHUB_OUTPUT
exit 0
fi
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")
# Create batches using shell commands
REPO_COUNT=$(jq '. | length' renovate-repos.json)
if [ "$REPO_COUNT" -eq 0 ]; then
echo "No repositories found"
echo "batches=[]" >> $GITHUB_OUTPUT
exit 0
fi
echo "Found $REPO_COUNT repositories"
# Create batches of 5 repos
BATCHES="["
for i in $(seq 0 5 $((REPO_COUNT-1))); do
if [ "$i" -gt 0 ]; then
BATCHES="$BATCHES,"
fi
# Create a batch of up to 5 repos
BATCH="["
for j in $(seq 0 4); do
IDX=$((i+j))
if [ "$IDX" -lt "$REPO_COUNT" ]; then
if [ "$j" -gt 0 ]; then
BATCH="$BATCH,"
fi
REPO=$(jq -r ".[$IDX]" renovate-repos.json)
BATCH="$BATCH\"$REPO\""
fi
done
BATCH="$BATCH]"
BATCHES="$BATCHES$BATCH"
done
BATCHES="$BATCHES]"
echo "Created batches: $BATCHES"
echo "batches=$BATCHES" >> $GITHUB_OUTPUT
echo "Created $(echo "$BATCHES" | jq '. | length') batches"
renovate:
name: Run Renovate
@ -86,41 +104,39 @@ jobs:
- 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: Install Renovate
run: |
npm install -g 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")
# Convert batch to string and process safely
BATCH='${{ toJson(matrix.batch) }}'
# Check if batch is valid
if [ "$BATCH" = "null" ] || [ "$BATCH" = "" ]; then
echo "Batch is empty or null"
exit 0
fi
# Parse batch and run Renovate
REPOS=""
# Parse JSON array using bash
BATCH=${BATCH//\[/}
BATCH=${BATCH//\]/}
BATCH=${BATCH//\"/}
BATCH=${BATCH//,/ }
for REPO in $BATCH; do
if [ -n "$REPO" ]; then
if [ -n "$REPOS" ]; then
REPOS="$REPOS,$REPO"
else
REPOS="$REPO"
fi
fi
done
if [ -n "$REPOS" ]; then
echo "Processing repositories: $REPOS"
renovate $REPOS
@ -128,12 +144,10 @@ jobs:
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)
@ -145,26 +159,15 @@ jobs:
- 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: Install Renovate
run: |
npm install -g renovate
- name: Run Renovate
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