-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-topics.ps1
More file actions
74 lines (64 loc) · 2.14 KB
/
add-topics.ps1
File metadata and controls
74 lines (64 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# PowerShell script to add topics to GitHub repository
# Requires GitHub Personal Access Token with repo scope
param(
[Parameter(Mandatory=$true)]
[string]$GitHubToken,
[Parameter(Mandatory=$false)]
[string]$Owner = "LABOSO123",
[Parameter(Mandatory=$false)]
[string]$Repo = "Femora"
)
# Valid topics - all start with lowercase, max 50 chars, hyphens allowed
$topics = @(
"women-health",
"menstrual-cycle",
"period-tracker",
"fertility-tracker",
"reproductive-health",
"cycle-tracking",
"javascript",
"html5",
"css3",
"vanilla-javascript",
"calendar",
"symptom-tracker",
"contraceptive-tracker",
"menopause",
"health-app",
"web-app",
"pwa",
"kenya",
"healthcare"
)
# Validate topics meet GitHub requirements
foreach ($topic in $topics) {
if ($topic -notmatch '^[a-z0-9]') {
Write-Warning "Topic '$topic' doesn't start with lowercase letter or number"
}
if ($topic.Length -gt 50) {
Write-Warning "Topic '$topic' exceeds 50 characters"
}
if ($topic -notmatch '^[a-z0-9][a-z0-9-]*$') {
Write-Warning "Topic '$topic' contains invalid characters"
}
}
$headers = @{
"Accept" = "application/vnd.github.mercy-preview+json"
"Authorization" = "token $GitHubToken"
}
$body = @{
names = $topics
} | ConvertTo-Json
$uri = "https://api.github.com/repos/$Owner/$Repo/topics"
try {
$response = Invoke-RestMethod -Uri $uri -Method PUT -Headers $headers -Body $body -ContentType "application/json"
Write-Host "✅ Successfully added topics to repository!" -ForegroundColor Green
Write-Host "Topics added: $($response.names -join ', ')" -ForegroundColor Cyan
} catch {
Write-Host "❌ Error adding topics: $($_.Exception.Message)" -ForegroundColor Red
Write-Host ""
Write-Host "To use this script:" -ForegroundColor Yellow
Write-Host "1. Create a GitHub Personal Access Token at: https://github.com/settings/tokens" -ForegroundColor Yellow
Write-Host "2. Give it 'repo' scope" -ForegroundColor Yellow
Write-Host "3. Run: .\add-topics.ps1 -GitHubToken 'your-token-here'" -ForegroundColor Yellow
}