-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (124 loc) · 4.93 KB
/
Copy pathnews.yml
File metadata and controls
147 lines (124 loc) · 4.93 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
name: Danish News Bot - Scheduled
on:
schedule:
# Adjust schedule as you like (UTC)
- cron: '0 6 * * *' # 08:00 Denmark — утренние новости
- cron: '0 8 * * *' # 10:00 Denmark — утренний дополнительный
- cron: '0 11 * * *' # 13:00 Denmark — обеденный выпуск
- cron: '0 15 * * *' # 17:00 Denmark — конец рабочего дня
- cron: '0 19 * * *' # 21:00 Denmark — вечерний прайм
workflow_dispatch: { }
jobs:
run-bot:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read # Read-only mode - bot only writes to database
env:
# PostgreSQL Database - КРИТИЧЕСКИ ВАЖНО для предотвращения дубликатов!
DATABASE_URL: ${{ secrets.DATABASE_URL }}
USE_POSTGRES: 'true'
# Cache settings (fallback if PostgreSQL fails)
CACHE_FILE_PATH: sent_news.json
CACHE_TTL_HOURS: 48
# Bot configuration — publish limit defaults to 1 per run (configurable via PUBLISH_LIMIT)
MAX_GEMINI_REQUESTS: 10
BOT_MODE: single
SCRAPE_CONCURRENCY: 1
# Feature flags (NEW)
ENABLE_THREAD_MODE: 'false'
ENABLE_INLINE_BUTTONS: 'true'
INLINE_BUTTON_MODE: 'url'
ENABLE_IMPORTANCE_LINE: 'true'
ENABLE_VOCAB_POST: 'false'
VOCAB_WORDS_PER_DAY: 5
# Website generation (DISABLED - site builds from Supabase)
ENABLE_WEBSITE: 'false'
WEBSITE_CONTENT_DIR: 'website/content'
# API Keys and Tokens
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
GEMINI_API_KEY_2: ${{ secrets.GEMINI_API_KEY_2 }}
GEMINI_API_KEY_3: ${{ secrets.GEMINI_API_KEY_3 }}
GEMINI_MODEL: gemini-3.5-flash
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
AI_PROVIDERS: "gemini,groq"
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
MISTRALAI_API_KEY: ${{ secrets.MISTRALAI_API_KEY }}
AI_REQUEST_DELAY_SECONDS: '8'
MIN_KEYWORD_SCORE: '6'
# Supabase (for website archive) - AUTO-ENABLED when credentials present
# Bot saves all news here, website pulls from this database
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }}
# Go settings
GO111MODULE: 'on'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26.x'
cache: true
- name: Go env (debug)
run: |
go version
go env GOMOD GOWORK GO111MODULE GOPATH GOTOOLCHAIN
pwd
ls -la
# Оставляем файловый кеш как fallback, но теперь PostgreSQL - основной источник
- name: Restore sent_news.json cache (fallback)
id: cache-sent
uses: actions/cache@v4
continue-on-error: true
with:
path: sent_news.json
key: sent-news-${{ runner.os }}-${{ github.ref_name }}-${{ github.run_id }}
restore-keys: |
sent-news-${{ runner.os }}-${{ github.ref_name }}-
sent-news-${{ runner.os }}-
sent-news-
- name: Show restored cache file (if any)
run: |
echo "Workspace: $PWD"
ls -la
echo "--- sent_news.json (restored) ---"
test -f sent_news.json && cat sent_news.json || echo "No previous cache"
- name: Prepare deps and bin dir
run: |
go mod download
mkdir -p bin
working-directory: ${{ github.workspace }}
- name: Build
run: |
go build -o bin/dknews ./cmd/dknews
working-directory: ${{ github.workspace }}
- name: Run bot
run: |
echo "🚀 Starting Danish News Bot..."
echo "Database mode: PostgreSQL (primary) + File cache (fallback)"
./bin/dknews | tee run.log
working-directory: ${{ github.workspace }}
# Website posts are now generated on-the-fly during site deployment
# No git commits needed - bot only saves to Supabase database
- name: Show resulting cache file
run: |
echo "--- sent_news.json (after run) ---"
test -f sent_news.json && cat sent_news.json || echo "Cache file not created (using PostgreSQL)"
working-directory: ${{ github.workspace }}
- name: Upload run log (optional)
if: always()
uses: actions/upload-artifact@v4
with:
name: run-log-${{ github.run_number }}
path: run.log
if-no-files-found: ignore
- name: Upload sent_news.json as artifact (fallback)
if: always()
uses: actions/upload-artifact@v4
with:
name: sent-news-cache-${{ github.run_number }}
path: sent_news.json
if-no-files-found: warn