Update .gitea/workflows/renovate.yaml
Some checks failed
renovate / Discover Repositories (push) Failing after 3s
renovate / Run Renovate (push) Has been skipped
renovate / Run Renovate (Default) (push) Has been skipped

This commit is contained in:
Jan K9f 2025-03-27 17:10:42 +00:00
commit ab242fb0e6

View file

@ -10,7 +10,6 @@ jobs:
discover-repos: discover-repos:
name: Discover Repositories name: Discover Repositories
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ghcr.io/renovatebot/renovate:39.219.2
outputs: outputs:
repo-batches: ${{ steps.create-batches.outputs.batches }} repo-batches: ${{ steps.create-batches.outputs.batches }}
@ -18,71 +17,64 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Cache Renovate dependencies - name: Setup Renovate
uses: actions/cache@v4 uses: renovatebot/github-action@v39.221.0
with: with:
path: /tmp/renovate-cache configurationFile: config.js
key: ${{ runner.os }}-renovate-discovery-${{ hashFiles('config.js') }}-${{ github.run_id }} token: ${{ secrets.RENOVATE_TOKEN }}
restore-keys: |
${{ runner.os }}-renovate-discovery-${{ hashFiles('config.js') }}-
${{ runner.os }}-renovate-discovery-
- name: Discover Repositories - name: Discover Repositories
run: | run: |
renovate --write-discovered-repos=/tmp/renovate-repos.json renovate --write-discovered-repos=renovate-repos.json
env: env:
RENOVATE_CONFIG_FILE: "config.js" RENOVATE_CONFIG_FILE: "config.js"
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }} GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }}
LOG_LEVEL: "info" LOG_LEVEL: "info"
RENOVATE_CACHE_DIR: /tmp/renovate-cache
RENOVATE_AUTODISCOVER: "true" RENOVATE_AUTODISCOVER: "true"
- name: Create Repository Batches - name: Create Repository Batches
id: create-batches id: create-batches
shell: bash
run: | run: |
# Check if repos file exists and is not empty if [ ! -f renovate-repos.json ] || [ ! -s renovate-repos.json ]; then
if [ ! -f /tmp/renovate-repos.json ] || [ ! -s /tmp/renovate-repos.json ]; then echo "No repositories discovered or file not created"
echo "No repositories discovered or file not created/empty"
echo "batches=[]" >> $GITHUB_OUTPUT echo "batches=[]" >> $GITHUB_OUTPUT
exit 0 exit 0
fi fi
# Use node to process JSON instead of jq (Node.js is already installed in the container) # Read repositories and create batches of 5
node -e ' REPOS=$(cat renovate-repos.json)
const fs = require("fs");
try { # Use Python (available in GitHub Actions runner) for JSON processing
const data = fs.readFileSync("/tmp/renovate-repos.json", "utf8"); BATCHES=$(python3 -c '
let repos = []; import json
try { import sys
repos = JSON.parse(data);
if (!Array.isArray(repos)) { try:
repos = []; data = json.loads(sys.argv[1])
} if not isinstance(data, list):
} catch (e) { print("[]")
console.error("Invalid JSON:", e.message); sys.exit(0)
}
// Create batches of 5 repos # Create batches of 5
const batches = []; batches = []
for (let i = 0; i < repos.length; i += 5) { for i in range(0, len(data), 5):
batches.push(repos.slice(i, i + 5)); batches.append(data[i:i+5])
}
console.log(`Created ${batches.length} batches of repositories`); print(json.dumps(batches))
// Output for GitHub Actions except Exception as e:
fs.writeFileSync(process.env.GITHUB_OUTPUT, `batches=${JSON.stringify(batches)}\n`, {flag: "a"}); print(f"Error: {e}", file=sys.stderr)
} catch (e) { print("[]")
console.error("Error processing repositories:", e.message); ' "$REPOS")
fs.writeFileSync(process.env.GITHUB_OUTPUT, "batches=[]\n", {flag: "a"});
} echo "Created batches: $BATCHES"
' echo "batches=$BATCHES" >> $GITHUB_OUTPUT
renovate: renovate:
name: Run Renovate name: Run Renovate
needs: discover-repos needs: discover-repos
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ghcr.io/renovatebot/renovate:39.219.2
if: ${{ needs.discover-repos.outputs.repo-batches != '[]' }} if: ${{ needs.discover-repos.outputs.repo-batches != '[]' }}
strategy: strategy:
matrix: matrix:
@ -94,6 +86,12 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 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 - name: Cache Renovate dependencies
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -103,50 +101,56 @@ jobs:
${{ runner.os }}-renovate- ${{ runner.os }}-renovate-
- name: Run Renovate on Batch - name: Run Renovate on Batch
shell: bash
run: | run: |
# Use node to process the batch and generate comma-separated repo list # Simple approach to create comma-separated list
node -e ' REPOS=""
const batch = JSON.parse(process.argv[1]); # Make sure batch is not empty
if (batch && batch.length > 0) { if [ -n "$BATCH" ] && [ "$BATCH" != "null" ]; then
const repoList = batch.join(","); # Convert JSON array to comma-separated string
console.log(`Processing repositories: ${repoList}`); REPOS=$(python3 -c '
console.log(`::set-output name=repo_list::${repoList}`); import json
} else { import sys
console.log("No repositories to process in this batch");
console.log("::set-output name=repo_list::"); try:
} batch = json.loads(sys.argv[1])
' '${{ toJson(matrix.batch) }}' if isinstance(batch, list) and batch:
print(",".join(batch))
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
' "$BATCH")
fi
# Get the repo list from the node script output
REPOS=$(node -e 'console.log(process.env.BATCH_JSON ? JSON.parse(process.env.BATCH_JSON).join(",") : "")' )
# Run Renovate on the specific repositories if any were found
if [ -n "$REPOS" ]; then if [ -n "$REPOS" ]; then
echo "Processing: $REPOS" echo "Processing repositories: $REPOS"
renovate $REPOS renovate $REPOS
else else
echo "No repositories to process in this batch" echo "No repositories to process in this batch"
fi fi
env: env:
BATCH_JSON: ${{ toJson(matrix.batch) }} BATCH: ${{ toJson(matrix.batch) }}
RENOVATE_CONFIG_FILE: "config.js" RENOVATE_CONFIG_FILE: "config.js"
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }} GITHUB_COM_TOKEN: ${{ secrets.GH_TOKEN }}
LOG_LEVEL: "info" LOG_LEVEL: "info"
RENOVATE_CACHE_DIR: /tmp/renovate-cache RENOVATE_CACHE_DIR: /tmp/renovate-cache
# Fallback job in case no repositories are found or for handling config repositories
renovate-default: renovate-default:
name: Run Renovate (Default) name: Run Renovate (Default)
needs: discover-repos needs: discover-repos
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ghcr.io/renovatebot/renovate:39.219.2
if: ${{ needs.discover-repos.outputs.repo-batches == '[]' }} if: ${{ needs.discover-repos.outputs.repo-batches == '[]' }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 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 - name: Cache Renovate dependencies
uses: actions/cache@v4 uses: actions/cache@v4
with: with: