Files
renovate-test/forgejo-up.ps1
T

32 lines
1.8 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Startet ein lokales Forgejo (Git-Server) in Podman, legt den Bot-User "renovate" an
# und speichert ein frisches Access-Token in .forgejo-token (wird von renovate-update.ps1 gelesen).
$ts = Get-Date -Format 'yyyy-MM-dd-HH-mm-ss-fff'
$tokenFile = Join-Path $PSScriptRoot '.forgejo-token'
# 1. Container starten – beim ersten Mal anlegen.
# ENABLE_PUSH_CREATE_USER: ein 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
if ($LASTEXITCODE -ne 0) { throw 'Forgejo-Container konnte nicht gestartet werden' }
}
Write-Host 'Warte auf Forgejo ...'
do {
Start-Sleep -Seconds 1
try { $ready = (Invoke-WebRequest 'http://localhost:3000/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
Set-Content -Path $tokenFile -Value $token -NoNewline
Write-Host 'Forgejo läuft: http://localhost:3000 (Login: renovate / renovate-local-123)' -ForegroundColor Cyan
Write-Host "Token gespeichert in $tokenFile"