-
Notifications
You must be signed in to change notification settings - Fork 7
89 lines (76 loc) · 2.9 KB
/
Copy pathdigest.yml
File metadata and controls
89 lines (76 loc) · 2.9 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
name: ScoutBot — Weekly Sunday Digest
# Every Sunday at 10:00 WAT (09:00 UTC):
# 1. Sends the apology/update announcement (so latecomers who missed it get it)
# 2. Sends the weekly opportunity digest (last 7 days only)
#
# On push to main, runs a dry-run (builds email preview without sending).
on:
schedule:
- cron: '0 9 * * 0'
workflow_dispatch:
push:
branches: [main]
jobs:
digest:
runs-on: ubuntu-latest
timeout-minutes: 240
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Restore Google service account JSON
env:
SA_JSON: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }}
SA_JSON_B64: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON_B64 }}
run: |
if [ -n "$SA_JSON_B64" ]; then
echo "$SA_JSON_B64" | base64 -d > service_account.json
echo "Restored from base64-encoded secret."
elif [ -n "$SA_JSON" ]; then
printf '%s' "$SA_JSON" > service_account.json
echo "Restored from raw JSON secret."
else
echo "ERROR: Neither GOOGLE_SERVICE_ACCOUNT_JSON nor GOOGLE_SERVICE_ACCOUNT_JSON_B64 is set in repo secrets!" >&2
exit 1
fi
python -c "import json; json.load(open('service_account.json')); print('service_account.json is valid.')"
- name: Build .env file from secrets
run: |
cat > .env <<EOF
SENDER_EMAIL=${{ secrets.SENDER_EMAIL }}
GMAIL_APP_PASSWORD=${{ secrets.GMAIL_APP_PASSWORD }}
SPREADSHEET_ID=${{ secrets.SPREADSHEET_ID }}
FORM_SHEET_ID=1dFcnVvQjWkuYhN1rplICTY0j88KgvGqQ3FzYId2ru4s
GOOGLE_SERVICE_ACCOUNT_JSON=service_account.json
RECIPIENT_EMAILS=${{ secrets.RECIPIENT_EMAILS }}
TELEGRAM_BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID=${{ secrets.TELEGRAM_CHAT_ID }}
EOF
- name: Dry-run email digest (build preview without sending)
if: github.event_name == 'push'
run: python run.py --dry-run
- name: Send announcement / update email (catches any who missed it mid-week)
if: github.event_name != 'push'
run: python announce.py
- name: Send weekly opportunity digest
if: github.event_name != 'push'
run: python run.py --notify
- name: Send Telegram digest
if: github.event_name != 'push'
run: python telegram_notify.py
- name: Upload logs and preview
if: always()
uses: actions/upload-artifact@v4
with:
name: digest-logs
path: |
scoutbot.log
email_preview.html
if-no-files-found: ignore
retention-days: 14