Forgejo und Renovate in getrennte Skripte, PR-Zeitstempel lesbar
This commit is contained in:
1 parent
426b61c3a6
commit
cd2ce6b722
5 files changed
+77
-43
No files matched your search
+22
-33
@@ -1,55 +1,44 @@
|
||||
# Renovate-Lauf gegen ein lokales Forgejo (Git-Server im Container).
|
||||
# Renovate-Lauf gegen ein Forgejo (lokal per forgejo-up.ps1 gestartet).
|
||||
# Jeder Lauf erzeugt einen neuen Branch + PR mit Zeitstempel: renovate/<yyyy-MM-dd-HH-mm-ss-fff>-all
|
||||
$endpoint = 'http://localhost:3000'
|
||||
$repo = 'renovate/monorepo'
|
||||
$tokenFile = Join-Path $PSScriptRoot '.forgejo-token'
|
||||
|
||||
# Renovate braucht Node.js >= 24.11
|
||||
if ([version](node -v).TrimStart('v') -lt [version]'24.11.0') { throw "Renovate braucht Node.js >= 24.11, gefunden: $(node -v). Z. B.: volta install node@24" }
|
||||
$ts = Get-Date -Format 'yyyy-MM-dd-HH-mm-ss-fff'
|
||||
$forgejo = 'http://localhost:3000'
|
||||
# Forgejo muss laufen und ein Token muss vorhanden sein
|
||||
try { Invoke-WebRequest "$endpoint/api/healthz" -UseBasicParsing | Out-Null } catch { throw "Forgejo unter $endpoint nicht erreichbar – zuerst .\forgejo-up.ps1 ausführen" }
|
||||
if (-not (Test-Path $tokenFile)) { throw "$tokenFile fehlt – zuerst .\forgejo-up.ps1 ausführen" }
|
||||
|
||||
$token = (Get-Content $tokenFile -Raw).Trim()
|
||||
$now = Get-Date
|
||||
$ts = $now.ToString('yyyy-MM-dd-HH-mm-ss-fff') # für den Branch-Namen (keine ':' oder Leerzeichen erlaubt)
|
||||
$prTimestamp = $now.ToString('yyyy-MM-dd HH:mm:ss.fff') # für den PR-Titel
|
||||
$gitUrl = $endpoint -replace '://', "://renovate:$token@"
|
||||
$gitUrl = "$gitUrl/$repo.git"
|
||||
Push-Location $PSScriptRoot
|
||||
|
||||
# 1. Forgejo starten – beim ersten Mal den Container anlegen.
|
||||
# ENABLE_PUSH_CREATE_USER: das Repo wird beim ersten "git push" automatisch angelegt.
|
||||
podman start renovate-forgejo 2>$null | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
podman run -d --name renovate-forgejo -p 3000:3000 -v renovate-forgejo-data:/data `
|
||||
-e FORGEJO__security__INSTALL_LOCK=true `
|
||||
-e FORGEJO__repository__ENABLE_PUSH_CREATE_USER=true `
|
||||
-e FORGEJO__repository__DEFAULT_BRANCH=main `
|
||||
codeberg.org/forgejo/forgejo:11 | Out-Null
|
||||
}
|
||||
Write-Host 'Warte auf Forgejo ...'
|
||||
do {
|
||||
Start-Sleep -Seconds 1
|
||||
try { $ready = (Invoke-WebRequest "$forgejo/api/healthz" -UseBasicParsing).StatusCode -eq 200 } catch { $ready = $false }
|
||||
} until ($ready)
|
||||
|
||||
# 2. Bot-User anlegen (Fehler ignorieren, falls er schon existiert) und ein frisches Access-Token erzeugen
|
||||
podman exec -u git renovate-forgejo forgejo admin user create --admin --username renovate `
|
||||
--password renovate-local-123 --email renovate@localhost --must-change-password=false 2>$null | Out-Null
|
||||
$token = podman exec -u git renovate-forgejo forgejo admin user generate-access-token `
|
||||
--username renovate --token-name "renovate-$ts" --scopes all --raw
|
||||
$gitUrl = "http://renovate:$token@localhost:3000/renovate/monorepo.git"
|
||||
|
||||
# 3. Lokalen Stand von main nach Forgejo pushen (ohne Credential-Helper, die Zugangsdaten stehen in der URL)
|
||||
# 1. Lokalen Stand von main nach Forgejo pushen (ohne Credential-Helper, die Zugangsdaten stehen in der URL)
|
||||
git -c credential.helper= push $gitUrl main:main
|
||||
if ($LASTEXITCODE -ne 0) { Pop-Location; throw 'git push fehlgeschlagen' }
|
||||
|
||||
# 4. Renovate laufen lassen. Branch-Präfix mit Zeitstempel => jeder Lauf erzeugt einen neuen Branch + PR.
|
||||
# 2. Renovate laufen lassen. Branch-Präfix mit Zeitstempel => jeder Lauf erzeugt einen neuen Branch + PR.
|
||||
# branch-prefix-old verhindert, dass Renovate Branches früherer Läufe wiederverwendet.
|
||||
# Per Env-Variable: der Commit-Autor und der Zeitstempel im PR-Titel (commitMessageSuffix gibt es nicht als CLI-Flag).
|
||||
$env:RENOVATE_GIT_AUTHOR = 'Renovate Bot <renovate@localhost>'
|
||||
$env:RENOVATE_COMMIT_MESSAGE_SUFFIX = $ts
|
||||
$env:RENOVATE_COMMIT_MESSAGE_SUFFIX = $prTimestamp
|
||||
npx --yes renovate@44.149.3 `
|
||||
--platform=forgejo --endpoint="$forgejo/api/v1" --token=$token `
|
||||
--platform=forgejo --endpoint="$endpoint/api/v1" --token=$token `
|
||||
--onboarding=false --require-config=optional `
|
||||
--branch-prefix="renovate/$ts-" --branch-prefix-old="renovate/$ts-" `
|
||||
renovate/monorepo
|
||||
$repo
|
||||
$renovateExitCode = $LASTEXITCODE
|
||||
Remove-Item Env:RENOVATE_GIT_AUTHOR, Env:RENOVATE_COMMIT_MESSAGE_SUFFIX
|
||||
if ($renovateExitCode -ne 0) { Pop-Location; throw 'Renovate fehlgeschlagen' }
|
||||
|
||||
# 5. Renovate-Branches ins lokale Repo holen (als forgejo/renovate/...)
|
||||
# 3. Renovate-Branches ins lokale Repo holen (als forgejo/renovate/...)
|
||||
git -c credential.helper= fetch -q --prune $gitUrl '+refs/heads/renovate/*:refs/remotes/forgejo/renovate/*'
|
||||
Write-Host "`nNeuer Branch:" -ForegroundColor Cyan
|
||||
git branch -r --list "forgejo/renovate/$ts-*"
|
||||
Write-Host "PRs: $forgejo/renovate/monorepo/pulls (Login: renovate / renovate-local-123)"
|
||||
Write-Host "PRs: $endpoint/$repo/pulls (Login: renovate / renovate-local-123)"
|
||||
Pop-Location
|
||||
Reference in new issue
Block a user