-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush-to-dev-studio.ps1
More file actions
61 lines (50 loc) · 1.54 KB
/
Copy pathpush-to-dev-studio.ps1
File metadata and controls
61 lines (50 loc) · 1.54 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
$ErrorActionPreference = 'Stop'
$projectPath = Split-Path -Parent $MyInvocation.MyCommand.Path
$targetRemote = 'https://github.com/mmporong/dev-studio.git'
Write-Host "Project path: $projectPath"
Set-Location $projectPath
if (Test-Path '.git') {
Write-Host 'Standalone git repository already exists in unity-webgl-wrapper.'
} else {
Write-Host 'Initializing standalone git repository in unity-webgl-wrapper...'
git init
}
$remoteNames = @(git remote)
$hasOrigin = $remoteNames -contains 'origin'
if ($hasOrigin) {
$currentOrigin = git remote get-url origin
if ($currentOrigin -ne $targetRemote) {
Write-Host "Updating origin remote to $targetRemote"
git remote set-url origin $targetRemote
} else {
Write-Host 'Origin remote already set correctly.'
}
} else {
Write-Host "Adding origin remote: $targetRemote"
git remote add origin $targetRemote
}
Write-Host 'Adding files...'
git add .
$hasCommits = $true
try {
git rev-parse --verify HEAD | Out-Null
} catch {
$hasCommits = $false
}
if ($hasCommits) {
Write-Host 'Creating/update commit if there are changes...'
git commit -m "Update agent office site" 2>$null
if ($LASTEXITCODE -ne 0) {
Write-Host 'No new commit created (possibly no staged changes).'
}
} else {
Write-Host 'Creating initial commit...'
git commit -m "Initial commit"
}
Write-Host 'Renaming branch to main...'
git branch -M main
Write-Host 'Pushing to GitHub...'
git push -u origin main
Write-Host ''
Write-Host 'Push complete.'
Write-Host 'GitHub Pages will auto-deploy from the main branch push.'