Created
March 28, 2026 11:05
-
-
Save RobbWatershed/374e31c92801abf709400588ec1c7b82 to your computer and use it in GitHub Desktop.
migrate MD issue to codeberg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Write-Output "Waiting..." | |
| Start-Sleep -Seconds 305 # 5 mins and a few more secs | |
| Write-Output "Let's move!" | |
| Get-ChildItem '*.md' -File | ForEach-Object { | |
| $file = $_ | |
| $title = "" | |
| $descriptionStart = $false | |
| $description = "" | |
| #$labels = @() | |
| $labels = [System.Collections.Generic.List[int]]@() | |
| $reachedLabel = $false | |
| Get-Content $file | ForEach-Object { | |
| if ($descriptionStart) { | |
| $description += $_ + [Environment]::NewLine | |
| } else { | |
| # Name | |
| if ($_ -match '^# issue ([\d]+): (.+)') { | |
| $title = $Matches.2 | |
| } | |
| # Labels | |
| if ($_ -match '^Labels: (.+)' -or $reachedLabel) { | |
| $label = "" | |
| if ($reachedLabel) { | |
| $label = $_ | |
| } else { | |
| $label = $Matches.1 | |
| $reachedLabel = $true | |
| } | |
| if ($label -eq 'UX') { $labels += 1332693 } | |
| else { if ($label -eq 'technical') { $labels += 1332690 } | |
| else { if ($label -eq 'source') { $labels += 1332207 } | |
| else { if ($label -eq 'Q&A') { $labels += 1332198 } | |
| else { if ($label -eq 'more info needed') { $labels += 1332687 } | |
| else { if ($label -eq 'enhancement') { $labels += 1332186 } | |
| else { if ($label -eq 'bug') { $labels += 1332180 } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| if ($_.length -eq 0) { | |
| $reachedLabel = $false | |
| } | |
| # Description | |
| if ($_ -eq '---') { | |
| $descriptionStart = $true | |
| } | |
| } | |
| } | |
| Write-Output $title | |
| Write-Output $labels | |
| Write-Output $description | |
| # POST to API | |
| $token="token" | |
| if ($labels.count -gt 0) { | |
| $labelStr = ,$labels[0] | ConvertTo-Json -Compress | |
| Write-Output $labelStr | |
| $postParams = @{body=$description;labels=$labelStr;title=$title} | |
| } else { | |
| $postParams = @{body=$description;title=$title} | |
| } | |
| Write-Output $postParams | |
| $headers = @{Authorization="token "+$token} | |
| Invoke-WebRequest -Uri https://codeberg.org/api/v1/repos/user/repo/issues -Method POST -Headers $headers -Body $postParams | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment