36 lines
1.8 KiB
PowerShell
36 lines
1.8 KiB
PowerShell
# Starts a local Forgejo (Git server) in Podman, creates the bot user "renovate"
|
|
# and stores a fresh access token in .forgejo-token (read by renovate-update.ps1).
|
|
$ts = Get-Date -Format 'yyyy-MM-dd-HH-mm-ss-fff'
|
|
$tokenFile = Join-Path $PSScriptRoot '.forgejo-token'
|
|
$username = 'renovate'
|
|
$password = 'renovate'
|
|
|
|
# 1. Start the container - create it on first run.
|
|
# ENABLE_PUSH_CREATE_USER: a repository is created automatically on the first "git push".
|
|
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 'Could not start the Forgejo container' }
|
|
}
|
|
Write-Host 'Waiting for 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. Create the bot user (ignore the error if it already exists) and generate a fresh access token
|
|
podman exec -u git renovate-forgejo forgejo admin user create --admin --username $username `
|
|
--password $password --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 $username --token-name "renovate-$ts" --scopes all --raw
|
|
Set-Content -Path $tokenFile -Value $token -NoNewline
|
|
|
|
Write-Host "`nForgejo is running: http://localhost:3000" -ForegroundColor Cyan
|
|
Write-Host " Username: $username"
|
|
Write-Host " Password: $password"
|
|
Write-Host " Token saved to $tokenFile"
|