name: Renovate
on:
  workflow_dispatch:
    inputs:
      log_level:
        type: choice
        description: Log level
        default: INFO
        options:
          - DEBUG
          - INFO
          - WARN
          - ERROR
          - FATAL
  schedule:
    - cron: 0 2 * * *

jobs:
  renovate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install node
        uses: actions/setup-node@v4
        with:
          node-version: "22"

      - name: Install bun
        uses: oven-sh/setup-bun@v2

      - name: Cache Bun global packages
        uses: actions/cache@v4
        with:
          path: ~/.bun/install/global
          key: ${{ runner.os }}-bun-global-renovate-40
          restore-keys: |
            ${{ runner.os }}-bun-global-

      - name: Install Renovate
        run: bun install -g renovate@40

      - name: Run renovate
        run: LOG_LEVEL=${{ github.event.inputs.log_level || 'INFO' }} renovate --token ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }}
