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

This commit is contained in:
Jan K9f 2025-03-27 17:09:07 +00:00
commit 9422db0ad3

View file

@ -27,10 +27,6 @@ jobs:
${{ runner.os }}-renovate-discovery-${{ hashFiles('config.js') }}- ${{ runner.os }}-renovate-discovery-${{ hashFiles('config.js') }}-
${{ runner.os }}-renovate-discovery- ${{ runner.os }}-renovate-discovery-
- name: Install jq
run: |
apt-get update && apt-get install -y jq
- name: Discover Repositories - name: Discover Repositories
run: | run: |
renovate --write-discovered-repos=/tmp/renovate-repos.json renovate --write-discovered-repos=/tmp/renovate-repos.json
@ -52,29 +48,35 @@ jobs:
exit 0 exit 0
fi fi
# Verify the file contains valid JSON # Use node to process JSON instead of jq (Node.js is already installed in the container)
if ! jq empty /tmp/renovate-repos.json 2>/dev/null; then node -e '
echo "Invalid JSON in repositories file" const fs = require("fs");
echo "batches=[]" >> $GITHUB_OUTPUT try {
exit 0 const data = fs.readFileSync("/tmp/renovate-repos.json", "utf8");
fi let repos = [];
try {
repos = JSON.parse(data);
if (!Array.isArray(repos)) {
repos = [];
}
} catch (e) {
console.error("Invalid JSON:", e.message);
}
# Read the JSON array and create batches // Create batches of 5 repos
echo "Creating batches of repositories..." const batches = [];
batches=$(jq -c 'if type == "array" then . else [] end | _nwise(5) | [.[]]' /tmp/renovate-repos.json) for (let i = 0; i < repos.length; i += 5) {
batches.push(repos.slice(i, i + 5));
}
# Handle empty results console.log(`Created ${batches.length} batches of repositories`);
if [ "$batches" = "" ] || [ "$batches" = "null" ]; then // Output for GitHub Actions
echo "No valid repositories found" fs.writeFileSync(process.env.GITHUB_OUTPUT, `batches=${JSON.stringify(batches)}\n`, {flag: "a"});
echo "batches=[]" >> $GITHUB_OUTPUT } catch (e) {
exit 0 console.error("Error processing repositories:", e.message);
fi fs.writeFileSync(process.env.GITHUB_OUTPUT, "batches=[]\n", {flag: "a"});
}
# Format as proper JSON array for GitHub Actions output '
batches="[$(echo "$batches" | tr '\n' ',' | sed 's/,$//' )]"
echo "batches=$batches" >> $GITHUB_OUTPUT
echo "Created $(echo "$batches" | jq '. | length') batches of repositories"
renovate: renovate:
name: Run Renovate name: Run Renovate
@ -100,31 +102,33 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-renovate- ${{ runner.os }}-renovate-
- name: Install jq
run: |
apt-get update && apt-get install -y jq
- name: Run Renovate on Batch - name: Run Renovate on Batch
run: | run: |
# Simple processing of batch array without complex jq # Use node to process the batch and generate comma-separated repo list
REPOS="" node -e '
for repo in $(echo '${{ toJson(matrix.batch) }}' | jq -r '.[]'); do const batch = JSON.parse(process.argv[1]);
if [ -n "$REPOS" ]; then if (batch && batch.length > 0) {
REPOS="$REPOS,$repo" const repoList = batch.join(",");
else console.log(`Processing repositories: ${repoList}`);
REPOS="$repo" console.log(`::set-output name=repo_list::${repoList}`);
fi } else {
done console.log("No repositories to process in this batch");
console.log("::set-output name=repo_list::");
}
' '${{ toJson(matrix.batch) }}'
echo "Processing repositories: $REPOS" # 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 # Run Renovate on the specific repositories if any were found
if [ -n "$REPOS" ]; then if [ -n "$REPOS" ]; then
echo "Processing: $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) }}
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 }}