diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..7b33740
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,3 @@
+BOT_TOKEN=
+TG_CHAT_ID=
+TG_THREAD_ID=
diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml
index 4f61b32..595be0b 100644
--- a/.gitea/workflows/build.yml
+++ b/.gitea/workflows/build.yml
@@ -13,6 +13,9 @@ jobs:
build:
runs-on:
- win11
+ env:
+ TG_CHAT_ID: ${{ secrets.TG_CHAT_ID }}
+ TG_THREAD_ID: ${{ secrets.TG_THREAD_ID }}
defaults:
run:
@@ -50,6 +53,17 @@ jobs:
New-Item -ItemType Directory -Path ".tools\\lslib" -Force | Out-Null
New-Item -ItemType Directory -Path "build" -Force | Out-Null
+ - name: Notify Telegram about build start
+ if: startsWith(gitea.ref, 'refs/tags/v')
+ continue-on-error: true
+ env:
+ BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
+ run: |
+ $ErrorActionPreference = "Stop"
+ $runUrl = "${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}"
+ $text = "⏳ Старт сборки релиза`nРепозиторий: ${{ gitea.repository }}`nТег: ${{ gitea.ref_name }}`nОткрыть лог сборки"
+ .\scripts\send-telegram-notification.ps1 -BotToken $env:BOT_TOKEN -ChatId $env:TG_CHAT_ID -ThreadId $env:TG_THREAD_ID -Text $text -DisableNotification
+
- name: Download latest LSLib release
run: |
$ErrorActionPreference = "Stop"
@@ -169,3 +183,25 @@ jobs:
}
Invoke-WebRequest -UseBasicParsing -Method Post -Uri "$apiBase/releases/$($release.id)/assets?name=$([uri]::EscapeDataString($assetName))" -Headers $uploadHeaders -ContentType "application/octet-stream" -InFile $zipPath
+
+ - name: Notify Telegram about build success
+ if: success() && startsWith(gitea.ref, 'refs/tags/v')
+ continue-on-error: true
+ env:
+ BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
+ run: |
+ $ErrorActionPreference = "Stop"
+ $releaseUrl = "${{ gitea.server_url }}/${{ gitea.repository }}/releases/tag/${{ gitea.ref_name }}"
+ $text = "🏁 Релиз собран успешно`nТег: ${{ gitea.ref_name }}`nОткрыть готовый релиз"
+ .\scripts\send-telegram-notification.ps1 -BotToken $env:BOT_TOKEN -ChatId $env:TG_CHAT_ID -ThreadId $env:TG_THREAD_ID -Text $text -DisableNotification
+
+ - name: Notify Telegram about build failure
+ if: failure() && startsWith(gitea.ref, 'refs/tags/v')
+ continue-on-error: true
+ env:
+ BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
+ run: |
+ $ErrorActionPreference = "Stop"
+ $runUrl = "${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}"
+ $text = "❌ Сборка релиза завершилась ошибкой`nТег: ${{ gitea.ref_name }}`nОткрыть лог сборки"
+ .\scripts\send-telegram-notification.ps1 -BotToken $env:BOT_TOKEN -ChatId $env:TG_CHAT_ID -ThreadId $env:TG_THREAD_ID -Text $text
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0075959..fc8cb04 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -12,10 +12,10 @@ permissions:
jobs:
build:
runs-on: windows-latest
- environment: TgBot
+ environment: Configure TgBot
env:
- TG_CHAT_ID: -1003975565934
- TG_THREAD_ID: 2
+ TG_CHAT_ID: ${{ secrets.TG_CHAT_ID }}
+ TG_THREAD_ID: ${{ secrets.TG_THREAD_ID }}
defaults:
run:
diff --git a/.gitignore b/.gitignore
index db513d5..1d40aff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,10 @@ build/
build-stage*
.tools/
.cache/
+.env
+.env.local
+.env.*
+!.env.example
*.pak
*.tmp
*.temp
diff --git a/AGENTS.md b/AGENTS.md
index 600b3f7..c35f62d 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -34,8 +34,8 @@ Approval/clarification:
- Branch (`fix/*` or `feat/*`): ask once before the first file-changing task that may lead to commit; reuse decision for all subsequent tasks in same dialogue.
After work in `fix/*` or `feat/*`:
-1. merge changes directly into `main` and delete the source branch
-2. create PR/MR targeting `main`
+1. create PR/MR targeting `main`
+2. merge changes into `main` and delete the source branch
Push failure:
- retry ≤2 times, 3s delay
@@ -70,6 +70,8 @@ Forbidden:
- CI: `.gitea/workflows/build.yml`
- Glossary: `glossary/glossary.normalized.json` _(primary terminology reference)_
- Actions: `ACTIONS.md`
+- Local env template: `.env.example`
+- Local env file: `.env.local`
- Upstream EN reference: `https://github.com/Yoonmoonsik/dnd55e/blob/main/Mods/DnD2024_897914ef-5c96-053c-44af-0be823f895fe/Localization/English/english.xml`
---
diff --git a/scripts/send-telegram-notification.ps1 b/scripts/send-telegram-notification.ps1
index f4203cc..5cb28e1 100644
--- a/scripts/send-telegram-notification.ps1
+++ b/scripts/send-telegram-notification.ps1
@@ -1,12 +1,12 @@
[CmdletBinding()]
param(
- [Parameter(Mandatory = $true)]
+ [Parameter()]
[string]$BotToken,
- [Parameter(Mandatory = $true)]
+ [Parameter()]
[string]$ChatId,
- [Parameter(Mandatory = $true)]
+ [Parameter()]
[string]$ThreadId,
[Parameter(Mandatory = $true)]
@@ -17,6 +17,80 @@ param(
$ErrorActionPreference = "Stop"
+function Import-DotEnvFile {
+ param(
+ [Parameter(Mandatory = $true)]
+ [string]$Path
+ )
+
+ if (-not (Test-Path -LiteralPath $Path)) {
+ return
+ }
+
+ foreach ($line in [System.IO.File]::ReadAllLines($Path)) {
+ $trimmedLine = $line.Trim()
+ if (-not $trimmedLine -or $trimmedLine.StartsWith("#")) {
+ continue
+ }
+
+ $separatorIndex = $trimmedLine.IndexOf("=")
+ if ($separatorIndex -lt 1) {
+ continue
+ }
+
+ $name = $trimmedLine.Substring(0, $separatorIndex).Trim()
+ $value = $trimmedLine.Substring($separatorIndex + 1).Trim()
+
+ if (
+ ($value.StartsWith('"') -and $value.EndsWith('"')) -or
+ ($value.StartsWith("'") -and $value.EndsWith("'"))
+ ) {
+ $value = $value.Substring(1, $value.Length - 2)
+ }
+
+ [System.Environment]::SetEnvironmentVariable($name, $value, "Process")
+ }
+}
+
+function Resolve-Setting {
+ param(
+ [string]$ExplicitValue,
+ [Parameter(Mandatory = $true)]
+ [string]$EnvName
+ )
+
+ if (-not [string]::IsNullOrWhiteSpace($ExplicitValue)) {
+ return $ExplicitValue
+ }
+
+ $envValue = [System.Environment]::GetEnvironmentVariable($EnvName, "Process")
+ if (-not [string]::IsNullOrWhiteSpace($envValue)) {
+ return $envValue
+ }
+
+ return $null
+}
+
+$repoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot ".."))
+$localEnvPath = Join-Path $repoRoot ".env.local"
+Import-DotEnvFile -Path $localEnvPath
+
+$BotToken = Resolve-Setting -ExplicitValue $BotToken -EnvName "BOT_TOKEN"
+$ChatId = Resolve-Setting -ExplicitValue $ChatId -EnvName "TG_CHAT_ID"
+$ThreadId = Resolve-Setting -ExplicitValue $ThreadId -EnvName "TG_THREAD_ID"
+
+if ([string]::IsNullOrWhiteSpace($BotToken)) {
+ throw "Telegram bot token is required. Pass -BotToken or set BOT_TOKEN in .env.local."
+}
+
+if ([string]::IsNullOrWhiteSpace($ChatId)) {
+ throw "Telegram chat id is required. Pass -ChatId or set TG_CHAT_ID in .env.local."
+}
+
+if ([string]::IsNullOrWhiteSpace($ThreadId)) {
+ throw "Telegram thread id is required. Pass -ThreadId or set TG_THREAD_ID in .env.local."
+}
+
$normalizedText = $Text.
Replace("``r``n", "`r`n").
Replace("``n", "`n").