Repository navigation
Expand file tree
/
Copy pathpush_to_github.ps1
More file actions
47 lines (39 loc) · 1.42 KB
/
Copy pathpush_to_github.ps1
File metadata and controls
47 lines (39 loc) · 1.42 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
$ErrorActionPreference = "Stop"
$token = "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"
$headers = @{
Authorization = "token $token"
Accept = "application/vnd.github.v3+json"
}
Write-Host "Authenticating with GitHub..."
try {
$userResponse = Invoke-RestMethod -Uri "https://api.github.com/user" -Headers $headers -Method Get
$username = $userResponse.login
Write-Host "Authenticated as: $username"
} catch {
Write-Host "Failed to authenticate with GitHub. Check your token."
exit 1
}
Write-Host "Creating repository 'safedesk'..."
$repoName = "safedesk"
$body = @{
name = $repoName
private = $false
description = "SafeDesk - Remote Desktop Software"
} | ConvertTo-Json
try {
$repoResponse = Invoke-RestMethod -Uri "https://api.github.com/user/repos" -Headers $headers -Method Post -Body $body -ContentType "application/json"
Write-Host "Created repository: $($repoResponse.html_url)"
} catch {
Write-Host "Repository might already exist or creation failed. Proceeding anyway."
}
Write-Host "Committing changes..."
git config user.email "dec@safedesk.local"
git config user.name "dec"
git add -A
git commit -m "Renamed to SafeDesk and updated icons"
git branch -M main
Write-Host "Pushing to GitHub..."
$remoteUrl = "https://${username}:${token}@github.com/${username}/${repoName}.git"
git remote set-url origin $remoteUrl
git push -u origin main
Write-Host "Done! Successfully pushed to GitHub."