This commit is contained in:
Dmitrii Prokudin 2024-12-25 04:30:40 +03:00
parent 7344f87538
commit ab41fbea38
3 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,38 @@
name: Local Deploy with Docker
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: self-hosted
steps:
# 1. Checkout репозиторий
- name: Checkout Repository
uses: actions/checkout@v3
# 2. Сборка Docker-образа
- name: Build Docker Image
run: |
docker build -t telegram-bot:latest .
# 3. Остановка и удаление старого контейнера (если существует)
- name: Stop and Remove Existing Container
run: |
docker stop telegram-bot || true
docker rm telegram-bot || true
# 4. Запуск нового контейнера
- name: Run New Docker Container
run: |
docker run -d --name telegram-bot \
--restart=always \
-e DATABASE_HOST=localhost \
-e DATABASE_NAME=telegram_bot \
-e DATABASE_USER=postgres \
-e DATABASE_PASSWORD=${{ secrets.DB_PASSWORD }} \
-e BOT_TOKEN=${{ secrets.BOT_TOKEN }} \
telegram-bot:latest

View File

@ -11,7 +11,7 @@ using Npgsql;
class Program class Program
{ {
private static string botToken = "7814259349:AAEasTnDpX5s5PrQcR5ihI9pOsmp2Ocv-m0"; // Укажите токен вашего бота private static string botToken = "7814259349:AAEasTnDpX5s5PrQcR5ihI9pOsmp2Ocv-m0"; // Укажите токен вашего бота
private static string connectionString = "Host=localhost;Port=5432;Database=telegram_bot;Username=postgres;Password=your_password"; private static string connectionString = "Host=localhost;Port=5432;Database=telegram_bot;Username=postgres;Password=postgres";
private static readonly TelegramBotClient botClient = new TelegramBotClient(botToken); private static readonly TelegramBotClient botClient = new TelegramBotClient(botToken);

View File

@ -14,4 +14,8 @@
<PackageReference Include="Telegram.Bot" Version="22.2.0" /> <PackageReference Include="Telegram.Bot" Version="22.2.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include=".gitea\workflows\deploy.yml" />
</ItemGroup>
</Project> </Project>