-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.ps1
More file actions
377 lines (312 loc) · 10.8 KB
/
deploy.ps1
File metadata and controls
377 lines (312 loc) · 10.8 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# ============================================================================
# Elite MT5 EA Showcase - Cloudflare Pages Deployment Script
# ============================================================================
# This script automates the deployment of the presentation to Cloudflare Pages
# via GitHub repository integration.
#
# Prerequisites:
# - Git must be installed
# - GitHub account
# - Cloudflare account (free tier works)
#
# Usage: .\deploy.ps1
# ============================================================================
param(
[string]$GitHubUsername = "",
[string]$RepoName = "ea-showcase",
[switch]$Help
)
# Color functions
function Write-ColorOutput($ForegroundColor) {
$fc = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = $ForegroundColor
if ($args) {
Write-Output $args
}
$host.UI.RawUI.ForegroundColor = $fc
}
function Write-Success { Write-ColorOutput Green $args }
function Write-Info { Write-ColorOutput Cyan $args }
function Write-Warning { Write-ColorOutput Yellow $args }
function Write-Error { Write-ColorOutput Red $args }
# Display header
function Show-Header {
Clear-Host
Write-ColorOutput Magenta @"
╔═══════════════════════════════════════════════════════════════╗
║ ║
║ 🚀 Elite MT5 EA Showcase - Deployment Script 🚀 ║
║ ║
║ Automated GitHub & Cloudflare Pages Setup ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
"@
}
# Display help
function Show-Help {
Write-Info @"
USAGE:
.\deploy.ps1 [-GitHubUsername <username>] [-RepoName <name>] [-Help]
PARAMETERS:
-GitHubUsername Your GitHub username (optional, will prompt if not provided)
-RepoName Repository name (default: ea-showcase)
-Help Display this help message
EXAMPLES:
.\deploy.ps1
.\deploy.ps1 -GitHubUsername "johndoe"
.\deploy.ps1 -GitHubUsername "johndoe" -RepoName "my-ea-showcase"
WHAT THIS SCRIPT DOES:
1. Checks prerequisites (Git installation)
2. Initializes Git repository
3. Creates .gitignore file
4. Commits all files
5. Creates GitHub repository (if GitHub CLI available)
6. Pushes code to GitHub
7. Provides Cloudflare Pages setup instructions
REQUIREMENTS:
- Git installed (https://git-scm.com/download/win)
- GitHub account
- Cloudflare account (free: https://dash.cloudflare.com/sign-up)
OPTIONAL:
- GitHub CLI (gh) for automated repo creation
Install: winget install --id GitHub.cli
"@
exit 0
}
# Check if Git is installed
function Test-GitInstalled {
try {
$gitVersion = git --version 2>$null
if ($gitVersion) {
Write-Success "✓ Git is installed: $gitVersion"
return $true
}
}
catch {
Write-Error "✗ Git is not installed!"
Write-Warning "`nPlease install Git from: https://git-scm.com/download/win"
Write-Warning "After installation, restart PowerShell and run this script again."
return $false
}
}
# Check if GitHub CLI is installed
function Test-GitHubCLI {
try {
$ghVersion = gh --version 2>$null
if ($ghVersion) {
Write-Success "✓ GitHub CLI is installed"
return $true
}
}
catch {
Write-Warning "✗ GitHub CLI not found (optional)"
Write-Info " To install: winget install --id GitHub.cli"
return $false
}
}
# Initialize Git repository
function Initialize-GitRepo {
Write-Info "`n📦 Initializing Git repository..."
if (Test-Path ".git") {
Write-Warning "Git repository already exists. Skipping initialization."
return $true
}
try {
git init | Out-Null
git branch -M main | Out-Null
Write-Success "✓ Git repository initialized"
return $true
}
catch {
Write-Error "✗ Failed to initialize Git repository: $_"
return $false
}
}
# Create .gitignore
function New-GitIgnore {
Write-Info "`n📝 Creating .gitignore file..."
$gitignoreContent = @"
# OS Files
.DS_Store
Thumbs.db
desktop.ini
# Editor Files
.vscode/
.idea/
*.swp
*.swo
*~
# Logs
*.log
# Temporary Files
*.tmp
*.temp
# Environment Files
.env
.env.local
# Build Files (if any)
/dist/
/build/
# Node Modules (if any)
node_modules/
# Backup Files
*.bak
*.backup
"@
try {
$gitignoreContent | Out-File -FilePath ".gitignore" -Encoding UTF8
Write-Success "✓ .gitignore created"
return $true
}
catch {
Write-Error "✗ Failed to create .gitignore: $_"
return $false
}
}
# Stage and commit files
function Invoke-GitCommit {
Write-Info "`n📝 Staging and committing files..."
try {
git add . | Out-Null
git commit -m "Initial commit: Elite MT5 EA Analysis Showcase" | Out-Null
Write-Success "✓ Files committed successfully"
return $true
}
catch {
Write-Error "✗ Failed to commit files: $_"
return $false
}
}
# Create GitHub repository (if GitHub CLI available)
function New-GitHubRepo {
param([string]$Username, [string]$RepoName)
Write-Info "`n🐙 Creating GitHub repository..."
if (Test-GitHubCLI) {
try {
Write-Info "Creating repository: $RepoName"
gh repo create $RepoName --public --source=. --remote=origin --push 2>&1 | Out-Null
if ($LASTEXITCODE -eq 0) {
Write-Success "✓ Repository created and code pushed!"
Write-Info " Repository URL: https://github.com/$Username/$RepoName"
return $true
}
else {
Write-Warning "GitHub CLI command failed. Will use manual method."
return $false
}
}
catch {
Write-Warning "Couldn't create repository automatically: $_"
return $false
}
}
return $false
}
# Manual GitHub setup instructions
function Show-ManualGitHubInstructions {
param([string]$Username, [string]$RepoName)
Write-Info "`n📖 Manual GitHub Setup Instructions:"
Write-Info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Write-Info "`n1. Go to: https://github.com/new"
Write-Info "2. Repository name: $RepoName"
Write-Info "3. Set to Public"
Write-Info "4. Do NOT initialize with README"
Write-Info "5. Click 'Create repository'"
Write-Info "`n6. Then run these commands:"
Write-ColorOutput Yellow @"
git remote add origin https://github.com/$Username/$RepoName.git
git push -u origin main
"@
}
# Cloudflare Pages setup instructions
function Show-CloudflareInstructions {
param([string]$Username, [string]$RepoName)
Write-Info "`n☁️ Cloudflare Pages Deployment Instructions:"
Write-Info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Write-ColorOutput Cyan @"
1. LOGIN TO CLOUDFLARE:
→ Go to: https://dash.cloudflare.com
→ Navigate to 'Pages' section
2. CREATE NEW PROJECT:
→ Click 'Create a project'
→ Click 'Connect to Git'
3. CONNECT GITHUB:
→ Authorize Cloudflare to access GitHub
→ Select repository: $RepoName
4. CONFIGURE BUILD SETTINGS:
Production branch: main
Build command: (leave empty)
Build output directory: /
Root directory: /
5. DEPLOY:
→ Click 'Save and Deploy'
→ Wait 1-2 minutes
→ Your site will be live at: https://$RepoName.pages.dev
6. OPTIONAL - CUSTOM DOMAIN:
→ In project settings, go to 'Custom domains'
→ Add your domain (e.g., ea-analysis.yourdomain.com)
→ Follow DNS configuration instructions
"@
}
# Success message
function Show-SuccessMessage {
param([string]$RepoName)
Write-Success "`n✨ DEPLOYMENT PREPARATION COMPLETE! ✨"
Write-Info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Write-Info "`nYour project is ready to deploy to Cloudflare Pages!"
Write-Info "`nNext steps:"
Write-Info " 1. Complete the GitHub repository setup (if not done automatically)"
Write-Info " 2. Follow the Cloudflare Pages instructions above"
Write-Info " 3. Your presentation will be live in minutes!"
Write-Info "`nPresentation password: eliteEA2024"
Write-Info "`nFor detailed documentation, see README.md"
Write-Info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`n"
}
# Main execution
function Main {
Show-Header
if ($Help) {
Show-Help
}
# Get GitHub username if not provided
if (-not $GitHubUsername) {
Write-Info "Please enter your GitHub username:"
$GitHubUsername = Read-Host "GitHub Username"
if (-not $GitHubUsername) {
Write-Error "GitHub username is required. Exiting."
exit 1
}
}
Write-Info "`nConfiguration:"
Write-Info " GitHub Username: $GitHubUsername"
Write-Info " Repository Name: $RepoName"
Write-Info "`nStarting deployment process..."
# Check prerequisites
if (-not (Test-GitInstalled)) {
exit 1
}
# Initialize repository
if (-not (Initialize-GitRepo)) {
exit 1
}
# Create .gitignore
New-GitIgnore | Out-Null
# Commit files
if (-not (Invoke-GitCommit)) {
exit 1
}
# Try to create GitHub repo automatically
$autoCreated = New-GitHubRepo -Username $GitHubUsername -RepoName $RepoName
# If auto-creation failed, show manual instructions
if (-not $autoCreated) {
Show-ManualGitHubInstructions -Username $GitHubUsername -RepoName $RepoName
Write-Info "`nPress any key after you've pushed to GitHub..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
# Show Cloudflare instructions
Show-CloudflareInstructions -Username $GitHubUsername -RepoName $RepoName
# Success message
Show-SuccessMessage -RepoName $RepoName
}
# Run the script
Main