Добавлены локальный env и Telegram-уведомления для CI
This commit is contained in:
3
.env.example
Normal file
3
.env.example
Normal file
@@ -0,0 +1,3 @@
|
||||
BOT_TOKEN=
|
||||
TG_CHAT_ID=
|
||||
TG_THREAD_ID=
|
||||
@@ -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 = "⏳ <b>Старт сборки релиза</b>`n<b>Репозиторий:</b> <code>${{ gitea.repository }}</code>`n<b>Тег:</b> <code>${{ gitea.ref_name }}</code>`n<a href=`"$runUrl`">Открыть лог сборки</a>"
|
||||
.\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 = "🏁 <b>Релиз собран успешно</b>`n<b>Тег:</b> <code>${{ gitea.ref_name }}</code>`n<a href=`"$releaseUrl`">Открыть готовый релиз</a>"
|
||||
.\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 = "❌ <b>Сборка релиза завершилась ошибкой</b>`n<b>Тег:</b> <code>${{ gitea.ref_name }}</code>`n<a href=`"$runUrl`">Открыть лог сборки</a>"
|
||||
.\scripts\send-telegram-notification.ps1 -BotToken $env:BOT_TOKEN -ChatId $env:TG_CHAT_ID -ThreadId $env:TG_THREAD_ID -Text $text
|
||||
|
||||
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@@ -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:
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -2,6 +2,10 @@ build/
|
||||
build-stage*
|
||||
.tools/
|
||||
.cache/
|
||||
.env
|
||||
.env.local
|
||||
.env.*
|
||||
!.env.example
|
||||
*.pak
|
||||
*.tmp
|
||||
*.temp
|
||||
|
||||
@@ -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`
|
||||
|
||||
---
|
||||
|
||||
@@ -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").
|
||||
|
||||
Reference in New Issue
Block a user