-
Notifications
You must be signed in to change notification settings - Fork 75
71 lines (62 loc) · 2.47 KB
/
reminder-bot-execution.yml
File metadata and controls
71 lines (62 loc) · 2.47 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
name: Mastodon Reminder Bot
on:
schedule:
# Run daily at 9 AM UTC
- cron: '0 9 * * *'
workflow_dispatch: # Allow manual triggering
jobs:
run-bot:
if: github.repository_owner == 'hackergarten'
runs-on: ubuntu-latest
environment: reminder-bot-automation
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
path: current-repo
- name: Checkout mastodon-reminder-bot repository
uses: actions/checkout@v4
with:
repository: hackergarten/mastodon-reminder-bot
path: bot-repo
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
working-directory: bot-repo
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Copy events.json to bot directory
run: |
cp current-repo/events.json bot-repo/events.json
- name: Validate environment variables
env:
MASTODON_API_BASE_URL: ${{ vars.MASTODON_API_BASE_URL }}
run: |
if [ -z "$MASTODON_API_BASE_URL" ]; then
echo "Error: MASTODON_API_BASE_URL is not set"
exit 1
fi
# Check if URL looks valid (should start with http:// or https://)
if [[ ! "$MASTODON_API_BASE_URL" =~ ^https?:// ]]; then
echo "Error: MASTODON_API_BASE_URL should start with http:// or https://"
echo "Current value starts with: ${MASTODON_API_BASE_URL:0:10}"
exit 1
fi
# Check if URL is not just "https://" or "http://"
if [[ "$MASTODON_API_BASE_URL" =~ ^https?://$ ]] || [[ "$MASTODON_API_BASE_URL" == "https" ]] || [[ "$MASTODON_API_BASE_URL" == "http" ]]; then
echo "Error: MASTODON_API_BASE_URL appears to be incomplete. It should be a full URL like https://mastodon.social"
exit 1
fi
echo "MASTODON_API_BASE_URL validation passed"
- name: Run mastodon reminder bot
working-directory: bot-repo
env:
MASTODON_API_BASE_URL: ${{ vars.MASTODON_API_BASE_URL }}
MASTODON_CLIENT_ID: ${{ secrets.MASTODON_CLIENT_ID }}
MASTODON_CLIENT_SECRET: ${{ secrets.MASTODON_CLIENT_SECRET }}
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
run: |
python mastodon-reminder.py events.json