# Renovate run against a Forgejo (started locally via script\forgejo-up.ps1). # Every run creates new branches + PRs with a timestamp: renovate/- $endpoint = 'http://localhost:3000' $repo = 'renovate/renovate-test' $tokenFile = Join-Path $PSScriptRoot '.forgejo-token' # Renovate requires Node.js >= 24.11 if ([version](node -v).TrimStart('v') -lt [version]'24.11.0') { throw "Renovate requires Node.js >= 24.11, found: $(node -v). E.g.: volta install node@24" } # Forgejo must be running and a token must exist try { Invoke-WebRequest "$endpoint/api/healthz" -UseBasicParsing | Out-Null } catch { throw "Forgejo is not reachable at $endpoint - run .\script\forgejo-up.ps1 first" } if (-not (Test-Path $tokenFile)) { throw "$tokenFile is missing - run .\script\forgejo-up.ps1 first" } $token = (Get-Content $tokenFile -Raw).Trim() $now = Get-Date $ts = $now.ToString('yyyy-MM-dd-HH-mm-ss-fff') # for the branch name (no ':' or spaces allowed) $prTimestamp = $now.ToString('yyyy-MM-dd HH:mm:ss.fff') # for the PR title $gitUrl = $endpoint -replace '://', "://renovate:$token@" $gitUrl = "$gitUrl/$repo.git" # Report and debug log of this run: reports// $outDir = Join-Path (Join-Path (Join-Path $PSScriptRoot '..') 'reports') $ts New-Item -ItemType Directory -Force -Path $outDir | Out-Null Push-Location (Join-Path $PSScriptRoot '..') # repository root # 1. Push the local state of main to Forgejo (without credential helper, the credentials are in the URL) git -c credential.helper= push $gitUrl main:main if ($LASTEXITCODE -ne 0) { Pop-Location; throw 'git push failed' } # 2. Run Renovate. Branch prefix with timestamp => every run creates new branches + PRs. # branch-prefix-old prevents Renovate from reusing branches of previous runs. # Via environment variables: the commit author, the timestamp in the PR title (commitMessageSuffix has no CLI flag) # and the debug log file (console output in the same format, but at debug level). $env:RENOVATE_GIT_AUTHOR = 'Renovate Bot ' $env:RENOVATE_COMMIT_MESSAGE_SUFFIX = $prTimestamp $env:LOG_FILE = Join-Path $outDir 'renovate.log' $env:LOG_FILE_LEVEL = 'debug' $env:LOG_FILE_FORMAT = 'pretty' npx --yes renovate@44.149.3 ` --platform=forgejo --endpoint="$endpoint/api/v1" --token=$token ` --branch-prefix="renovate/$ts-" --branch-prefix-old="renovate/$ts-" ` --report-type=file --report-path="$(Join-Path $outDir 'renovate-report.json')" ` $repo $renovateExitCode = $LASTEXITCODE Remove-Item Env:RENOVATE_GIT_AUTHOR, Env:RENOVATE_COMMIT_MESSAGE_SUFFIX, Env:LOG_FILE, Env:LOG_FILE_LEVEL, Env:LOG_FILE_FORMAT if ($renovateExitCode -ne 0) { Pop-Location; throw "Renovate failed - see $outDir" } # 3. Fetch the Renovate branches into the local repository (as forgejo/renovate/...) git -c credential.helper= fetch -q --prune $gitUrl '+refs/heads/renovate/*:refs/remotes/forgejo/renovate/*' Write-Host "`nNew branches:" -ForegroundColor Cyan git branch -r --list "forgejo/renovate/$ts-*" Write-Host "PRs: $endpoint/$repo/pulls (login: renovate / renovate)" Write-Host "Report and debug log: $outDir" Pop-Location