diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 0000000..b38a01c --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,41 @@ +# Deploy — audio-voice-converter + +اسکریپت‌های CI/CD پروژه `audio-voice-converter`. + +## ساختار + +``` +deploy/ +├── README.md ← این فایل +└── scripts/ + ├── sync.ps1 ← کپی فایل‌ها از source به repo + └── push.ps1 ← git commit + push به Gitea +``` + +## پیش‌نیازها + +- متغیر محیطی `AUDIO_SOURCE_ROOT` تنظیم شده باشه (مسیر پوشه‌ی source) +- دسترسی git به remote (credential یا SSH key) + +```powershell +$env:AUDIO_SOURCE_ROOT = "D:\projects\google_meet_captions" +``` + +## استفاده + +```powershell +# فقط sync (کپی فایل‌ها بدون push) +.\scripts\sync.ps1 + +# sync + commit + push +.\scripts\sync.ps1 | .\scripts\push.ps1 + +# یا مستقیم push (اگر sync قبلاً انجام شده) +.\scripts\push.ps1 +``` + +## جریان کلی + +``` +source dirs → sync.ps1 → repo files → push.ps1 → Gitea +``` diff --git a/deploy/scripts/push.ps1 b/deploy/scripts/push.ps1 new file mode 100644 index 0000000..040988c --- /dev/null +++ b/deploy/scripts/push.ps1 @@ -0,0 +1,56 @@ +<# +.SYNOPSIS + Git commit + push to Gitea (no sensitive data; credentials come from git config or env). + +.DESCRIPTION + Stages all changes, commits with a timestamp message, and force-pushes to origin/main. + Run from the repo root or any subdirectory. + + Remote URL is whatever `git remote get-url origin` returns — configure it once: + git remote set-url origin https://@/arash/audio-voice-converter.git + +.PARAMETER Message + Optional commit message. Defaults to "chore: sync extension files ". + +.PARAMETER DryRun + Show what would be committed/pushed without actually doing it. + +.EXAMPLE + .\deploy\scripts\push.ps1 + .\deploy\scripts\push.ps1 -Message "feat: update popup UI" + .\deploy\scripts\push.ps1 -DryRun +#> +[CmdletBinding()] +param( + [string]$Message, + [switch]$DryRun +) + +$ErrorActionPreference = "Stop" + +# Navigate to repo root (2 levels up from deploy/scripts/) +$repoRoot = Split-Path (Split-Path $PSScriptRoot) +Set-Location $repoRoot + +$status = git status --porcelain +if (-not $status) { + Write-Host "Nothing to commit." + exit 0 +} + +$msg = if ($Message) { $Message } else { "chore: sync extension files $(Get-Date -Format 'yyyy-MM-dd HH:mm')" } + +Write-Host "Changes to commit:" +git status --short + +if ($DryRun) { + Write-Host "[DryRun] Would commit: $msg" + Write-Host "[DryRun] Would push: origin main (force)" + exit 0 +} + +git add . +git commit -m $msg +git push --force origin main + +Write-Host "Push complete." diff --git a/deploy/scripts/sync.ps1 b/deploy/scripts/sync.ps1 new file mode 100644 index 0000000..642e6cd --- /dev/null +++ b/deploy/scripts/sync.ps1 @@ -0,0 +1,50 @@ +<# +.SYNOPSIS + Sync extension source files into this repo (no git operations). + +.DESCRIPTION + Copies the latest files from the source directories into the repo. + Source root is read from $env:AUDIO_SOURCE_ROOT (no sensitive data in this script). + + Source layout expected under $env:AUDIO_SOURCE_ROOT: + Google Meet Transcripts & AI Summary/ -> google-meet-transcripts-extension/ + caption-extension/ -> caption-extension/ + +.EXAMPLE + $env:AUDIO_SOURCE_ROOT = "D:\projects\google_meet_captions" + .\deploy\scripts\sync.ps1 +#> +[CmdletBinding()] +param() + +$ErrorActionPreference = "Stop" + +$sourceRoot = $env:AUDIO_SOURCE_ROOT +if (-not $sourceRoot) { + Write-Error "Set `$env:AUDIO_SOURCE_ROOT` to the google_meet_captions folder before running." +} + +$repoRoot = Split-Path (Split-Path $PSScriptRoot) # deploy/scripts -> repo root + +$mappings = @( + @{ + From = Join-Path $sourceRoot "Google Meet Transcripts & AI Summary" + To = Join-Path $repoRoot "google-meet-transcripts-extension" + }, + @{ + From = Join-Path $sourceRoot "caption-extension" + To = Join-Path $repoRoot "caption-extension" + } +) + +foreach ($m in $mappings) { + if (-not (Test-Path $m.From)) { + Write-Warning "Source not found, skipping: $($m.From)" + continue + } + Write-Host "Syncing $($m.From) -> $($m.To)" + New-Item -ItemType Directory -Force -Path $m.To | Out-Null + Copy-Item "$($m.From)\*" $m.To -Recurse -Force +} + +Write-Host "Sync complete."