name: Renovate # Dependency updates for this repository (renovate.json). Runs only on the Collection's own runner # (label kamino-docker), and no credential from anywhere else is used here. # The credential is the token of a Kamino-only bot user, held as # the repository secret RENOVATE_BOT_TOKEN (not an org secret: only image.yml may reference those). # The job token cannot be used: Renovate filters every pull request lookup by its own username, # which is the virtual user gitea-actions with the job token, and Gitea answers 400 "user does not # exist" (dry run 2445). No GitHub token exists (no RENOVATE_GITHUB_COM_TOKEN): the github-tags # datasource then skips every pre-commit hook (skipReason github-token-required, dry run 3880), and # unauthenticated GitHub API lookups are refused at once (403 rate limit). The hooks are looked up # with git ls-remote instead (renovate.json, packageRule overrideDatasource git-tags), which needs # RENOVATE_GITHUB_TOKEN_WARN=false below: the token check runs before package rules apply. # # Dry run: Actions > Renovate > Run workflow, dry_run=true (the default for a manual run), then # read the debug log. The schedule runs live, and so does a successful Images run's completion, so # the pin pull request for a new image version opens within minutes of its push. Gitea starts a # workflow_run only for a run a person triggered, and its event carries no input or credential. on: # yamllint disable-line rule:truthy # Images runs only on main (push, dispatch), and this job reads nothing from its run but the conclusion. workflow_run: # zizmor: ignore[dangerous-triggers] workflows: [Images] types: [completed] schedule: # Daily, off the hour so it avoids typical molecule and image runs. - cron: "17 3 * * *" workflow_dispatch: inputs: dry_run: description: "Log what Renovate would do without branches or pull requests" type: choice options: - "true" - "false" default: "true" # The job token is not used for Renovate (see above): read-only is enough for the job itself. permissions: contents: read # Never two runs at once; a running one is not cancelled (it may be mid-push). concurrency: group: renovate cancel-in-progress: false jobs: renovate: # Only in this repository (a copy elsewhere has no such secret), and not after a failed Images run. if: >- (github.repository == 'mortis/kamino' || github.repository == 'Mortis/Kamino') && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success') runs-on: kamino-docker timeout-minutes: 30 # Docker Hub image, pinned by digest. The -full flavour ships python3 for the report check # below and pip-compile for lock refreshes. Hand-bumped: renovate.json # disables updates for this file. The image sets RENOVATE_BINARY_SOURCE=global, so pip-compile # runs on the image's own python (3.14.8 in 44.161.0) and ignores the Python that Renovate # reads from the lock header: that python's minor version must equal .python-version, or a lock # refresh rewrites the header (check_image_versions.py pins then fails the pull request). When # bumping this image, check its python first; RENOVATE_BINARY_SOURCE=install would make Renovate # install the header's python, but it also downloads tools at run time (pip-tools included). container: image: renovate/renovate:44.161.0-full@sha256:ddbf02e44b542343c9df696b88fd953f04cc3ee5f771221805ff8efb26595416 steps: - name: Run Renovate env: RENOVATE_PLATFORM: gitea RENOVATE_ENDPOINT: ${{ github.server_url }}/api/v1/ RENOVATE_REPOSITORIES: ${{ github.repository }} RENOVATE_TOKEN: ${{ secrets.RENOVATE_BOT_TOKEN }} # Git auth: see the run block. The host the header is scoped to. GIT_HOST_URL: ${{ github.server_url }}/ RENOVATE_GIT_AUTHOR: "Renovate Bot " # No GitHub token exists, and the hooks go through git-tags (see the header). Without this # Renovate marks every github-tags dependency as skipped before the package rule applies. RENOVATE_GITHUB_TOKEN_WARN: "false" # Renovate exits 0 when a repository run fails (e.g. the clone): with this it exits with # an error-specific code instead (7 for an external host error such as a failed clone). RENOVATE_EXIT_CODE_FOR_ERRORS: "true" # The JSON report is checked after the run (see below). RENOVATE_REPORT_TYPE: file LOG_LEVEL: ${{ github.event_name == 'workflow_dispatch' && 'debug' || 'info' }} # Fail safe: only the schedule and workflow_run are live. A manual dispatch is a dry run unless # the input is exactly the string "false" (an empty input from an API or CLI dispatch stays one). DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run != 'false' && 'true' || 'false' }} run: | if [ -z "$RENOVATE_TOKEN" ]; then echo "::error::The repository secret RENOVATE_BOT_TOKEN is not set (token of the Kamino-only bot user)" exit 1 fi # Git over HTTPS with the bot token. Renovate's own rewrite puts the token in the URL # (https://@host/...), which git drops when the server redirects, and Gitea # redirected the clone (dry run 2439). The header is sent on every request to the host, # as lint.yml does with its token. Renovate does not pass GIT_CONFIG_* from its environment to git # (only an allowlist, util/exec/env.js), but it does pass HOME, so a global git config # is the path that reaches its git children. The token is read from the environment. git config --global "http.${GIT_HOST_URL}.extraheader" "AUTHORIZATION: bearer ${RENOVATE_TOKEN}" report="${RUNNER_TEMP:-/tmp}/renovate-report.json" rm -f "$report" export RENOVATE_REPORT_PATH="$report" if [ "$DRY_RUN" = "true" ]; then export RENOVATE_DRY_RUN=full fi rc=0 renovate || rc=$? if [ "$rc" -ne 0 ]; then echo "::error::Renovate exited with code $rc" exit "$rc" fi # Fail on a missing or unreadable report and on any ERROR (50) or FATAL (60) problem, # global or per repository. Warnings (40) do not fail the job. python3 -I -c ' import json, sys try: with open(sys.argv[1], encoding="utf-8") as handle: report = json.load(handle) except (OSError, ValueError) as err: sys.exit("::error::no readable Renovate report: " + str(err)) problems = list(report.get("problems", [])) for repo in report.get("repositories", {}).values(): problems.extend(repo.get("problems", [])) bad = [p for p in problems if p.get("level", 0) >= 50] for p in bad: print("::error::Renovate problem: " + str(p.get("msg", ""))) sys.exit(1 if bad else 0) ' "$report"