Update .gitea/workflows/renovate.yaml
Some checks failed
renovate / Discover Repositories (push) Failing after 6s
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:07:59 +00:00
commit 576722b60e

View file

@ -27,6 +27,10 @@ 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
@ -41,24 +45,33 @@ jobs:
- name: Create Repository Batches - name: Create Repository Batches
id: create-batches id: create-batches
run: | run: |
# Install jq (not included in Renovate image) # Check if repos file exists and is not empty
apt-get update && apt-get install -y jq if [ ! -f /tmp/renovate-repos.json ] || [ ! -s /tmp/renovate-repos.json ]; then
echo "No repositories discovered or file not created/empty"
# Check if repos file exists
if [ ! -f /tmp/renovate-repos.json ]; then
echo "No repositories discovered or file not created"
echo "batches=[]" >> $GITHUB_OUTPUT echo "batches=[]" >> $GITHUB_OUTPUT
exit 0 exit 0
fi fi
# Read the JSON array from the input file # Verify the file contains valid JSON
json_array=$(cat /tmp/renovate-repos.json) if ! jq empty /tmp/renovate-repos.json 2>/dev/null; then
echo "Invalid JSON in repositories file"
echo "batches=[]" >> $GITHUB_OUTPUT
exit 0
fi
# Group repositories into batches of 5 # Read the JSON array and create batches
echo "Creating batches of repositories..." echo "Creating batches of repositories..."
batches=$(echo "$json_array" | jq -r '.[]' | xargs -n5 | jq -R -s 'split("\n") | map(select(length > 0) | split(" "))' | jq 'del(.[] | select(. == []))' | jq -c .) batches=$(jq -c 'if type == "array" then . else [] end | _nwise(5) | [.[]]' /tmp/renovate-repos.json)
# Set the output for the next job # Handle empty results
if [ "$batches" = "" ] || [ "$batches" = "null" ]; then
echo "No valid repositories found"
echo "batches=[]" >> $GITHUB_OUTPUT
exit 0
fi
# Format as proper JSON array for GitHub Actions output
batches="[$(echo "$batches" | tr '\n' ',' | sed 's/,$//' )]"
echo "batches=$batches" >> $GITHUB_OUTPUT echo "batches=$batches" >> $GITHUB_OUTPUT
echo "Created $(echo "$batches" | jq '. | length') batches of repositories" echo "Created $(echo "$batches" | jq '. | length') batches of repositories"
@ -83,20 +96,34 @@ jobs:
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: /tmp/renovate-cache path: /tmp/renovate-cache
key: ${{ runner.os }}-renovate-batch-${{ join(matrix.batch, '-') }}-${{ hashFiles('config.js') }}-${{ github.run_id }} key: ${{ runner.os }}-renovate-batch-${{ github.run_id }}
restore-keys: | restore-keys: |
${{ runner.os }}-renovate-batch-${{ join(matrix.batch, '-') }}-${{ hashFiles('config.js') }}-
${{ runner.os }}-renovate-batch-${{ join(matrix.batch, '-') }}-
${{ 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: |
# Convert array to comma-separated list # Simple processing of batch array without complex jq
REPOS=$(echo '${{ toJson(matrix.batch) }}' | jq -r 'join(",")') REPOS=""
for repo in $(echo '${{ toJson(matrix.batch) }}' | jq -r '.[]'); do
if [ -n "$REPOS" ]; then
REPOS="$REPOS,$repo"
else
REPOS="$repo"
fi
done
echo "Processing repositories: $REPOS" echo "Processing repositories: $REPOS"
# Run Renovate on the specific repositories # Run Renovate on the specific repositories
if [ -n "$REPOS" ]; then
renovate $REPOS renovate $REPOS
else
echo "No repositories to process in this batch"
fi
env: env:
RENOVATE_CONFIG_FILE: "config.js" RENOVATE_CONFIG_FILE: "config.js"
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}