Skip to content

Commit

Permalink
add existing check
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Feb 12, 2025
1 parent f53725f commit a517b9b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Modules/CippExtensions/Public/GitHub/New-GitHubRepo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ function New-GitHubRepo {
$Path = 'user/repos'
}

# Check if repo exists
$Existing = Invoke-GitHubApiRequest -Path "$Path/$Name"
if ($Existing.id) {
return $Existing
}

if ($PSCmdlet.ShouldProcess("Create repository '$Name'")) {
Invoke-GitHubApiRequest -Path $Path -Method POST -Body $Body
return (Invoke-GitHubApiRequest -Path $Path -Method POST -Body $Body)
}
}

0 comments on commit a517b9b

Please sign in to comment.