Update .gitea/workflows/renovate.yaml
This commit is contained in:
parent
9422db0ad3
commit
ab242fb0e6
1 changed files with 65 additions and 61 deletions
|
@ -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 {
|
|
||||||
const data = fs.readFileSync("/tmp/renovate-repos.json", "utf8");
|
|
||||||
let repos = [];
|
|
||||||
try {
|
|
||||||
repos = JSON.parse(data);
|
|
||||||
if (!Array.isArray(repos)) {
|
|
||||||
repos = [];
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Invalid JSON:", e.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create batches of 5 repos
|
# Use Python (available in GitHub Actions runner) for JSON processing
|
||||||
const batches = [];
|
BATCHES=$(python3 -c '
|
||||||
for (let i = 0; i < repos.length; i += 5) {
|
import json
|
||||||
batches.push(repos.slice(i, i + 5));
|
import sys
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Created ${batches.length} batches of repositories`);
|
try:
|
||||||
// Output for GitHub Actions
|
data = json.loads(sys.argv[1])
|
||||||
fs.writeFileSync(process.env.GITHUB_OUTPUT, `batches=${JSON.stringify(batches)}\n`, {flag: "a"});
|
if not isinstance(data, list):
|
||||||
} catch (e) {
|
print("[]")
|
||||||
console.error("Error processing repositories:", e.message);
|
sys.exit(0)
|
||||||
fs.writeFileSync(process.env.GITHUB_OUTPUT, "batches=[]\n", {flag: "a"});
|
|
||||||
}
|
# 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:
|
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::");
|
|
||||||
}
|
|
||||||
' '${{ toJson(matrix.batch) }}'
|
|
||||||
|
|
||||||
# Get the repo list from the node script output
|
try:
|
||||||
REPOS=$(node -e 'console.log(process.env.BATCH_JSON ? JSON.parse(process.env.BATCH_JSON).join(",") : "")' )
|
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
|
||||||
|
|
||||||
# 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:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue