Aprendido desplegando cotizador (Next.js+FastAPI+Postgres, Docker Compose, repo privado) en coolify.urieljareth.org (v4.1.2): - Documenta que /applications/* devuelve 404 en esta instancia y que configurar apps git build-from-source solo es posible por la UI web. - Nuevos scripts scripts/coolify-ui/: coolify-login.mjs (guarda storageState) y Configure-CoolifyComposeApp.mjs (build pack -> Docker Compose, Reload Compose File, env vars por Developer view, dominios por servicio). - references/coolify-4.1.2-notes.md: mapa de API funcional/404, gotchas (BOM UTF-8 rompe el parser YAML de Coolify; Reload Compose File obligatorio; pin de dominios por servicio o 503; no encolar deploys concurrentes; PowerShell [IO.File]::ReadAllText para payloads de llaves). - env.local.template.ps1: COOLIFY_EMAIL/COOLIFY_PASSWORD para la UI. - SKILL.md/TOOLS.md: seccion "instance reality" y flujo UI paso a paso. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
86 lines
2.4 KiB
PowerShell
86 lines
2.4 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Create a new GitHub repository for a project that will be deployed to Coolify.
|
|
|
|
.DESCRIPTION
|
|
Calls the GitHub REST API with GITHUB_TOKEN to create a new repository under
|
|
the authenticated user. After creation, prints the clone URL (HTTPS) and the
|
|
SSH push URL. Idempotent in the sense that if the repo already exists it
|
|
aborts with a clear message instead of failing.
|
|
|
|
.PARAMETER Name
|
|
Repository name (required). GitHub naming rules: lowercase, digits, '-' '_' '.'.
|
|
|
|
.PARAMETER Description
|
|
Short description shown on GitHub.
|
|
|
|
.PARAMETER Private
|
|
Switch. If set, creates a private repository. Default is public (Coolify
|
|
public-app deploy does not need a deploy key).
|
|
|
|
.PARAMETER Owner
|
|
Optional. Organization or user to create the repo under. Defaults to the
|
|
authenticated user (the owner of GITHUB_TOKEN).
|
|
|
|
.EXAMPLE
|
|
.\New-GitHubRepo.ps1 -Name "my-cool-app" -Description "Demo" -Private
|
|
#>
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[ValidatePattern('^[A-Za-z0-9._-]+$')]
|
|
[string]$Name,
|
|
|
|
[string]$Description = "",
|
|
|
|
[switch]$Private,
|
|
|
|
[string]$Owner
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$ghApi = Join-Path $here "Invoke-GitHubApi.ps1"
|
|
|
|
$me = & $ghApi -Path "/user" -ErrorAction Stop
|
|
$effectiveOwner = if ($Owner) { $Owner } else { $me.login }
|
|
|
|
Write-Host "Authenticated GitHub user: $($me.login)" -ForegroundColor Cyan
|
|
|
|
$exists = $null
|
|
try {
|
|
$exists = & $ghApi -Path "/repos/$effectiveOwner/$Name" -ErrorAction Stop
|
|
} catch {
|
|
$exists = $null
|
|
}
|
|
if ($exists) {
|
|
Write-Host "Repository already exists: https://github.com/$effectiveOwner/$Name" -ForegroundColor Yellow
|
|
Write-Host "clone_url: $($exists.clone_url)"
|
|
return $exists
|
|
}
|
|
|
|
$body = [ordered]@{
|
|
name = $Name
|
|
description = $Description
|
|
private = [bool]$Private
|
|
auto_init = $true
|
|
has_issues = $true
|
|
has_wiki = $false
|
|
} | ConvertTo-Json -Compress
|
|
|
|
$endpoint = if ($Owner) { "/orgs/$Owner/repos" } else { "/user/repos" }
|
|
|
|
Write-Host "Creating repository at: $endpoint" -ForegroundColor Cyan
|
|
$created = & $ghApi -Method POST -Path $endpoint -BodyJson $body -ErrorAction Stop
|
|
|
|
[PSCustomObject]@{
|
|
full_name = $created.full_name
|
|
html_url = $created.html_url
|
|
clone_url = $created.clone_url
|
|
ssh_url = $created.ssh_url
|
|
private = $created.private
|
|
default_branch = $created.default_branch
|
|
} | Format-List
|
|
|
|
$created
|