Skip to content

Commit e2e2803

Browse files
authored
add mastodon reminder-bot action
1 parent bd9af9c commit e2e2803

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Mastodon Reminder Bot
2+
3+
on:
4+
schedule:
5+
# Run daily at 9 AM UTC
6+
- cron: '0 9 * * *'
7+
workflow_dispatch: # Allow manual triggering
8+
9+
jobs:
10+
run-bot:
11+
runs-on: ubuntu-latest
12+
environment: bot-automation
13+
14+
steps:
15+
- name: Checkout current repository
16+
uses: actions/checkout@v4
17+
with:
18+
path: current-repo
19+
20+
- name: Checkout mastodon-reminder-bot repository
21+
uses: actions/checkout@v4
22+
with:
23+
repository: hackergarten/mastodon-reminder-bot
24+
path: bot-repo
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.x'
30+
31+
- name: Install dependencies
32+
working-directory: bot-repo
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
36+
37+
- name: Copy events.json to bot directory
38+
run: |
39+
cp current-repo/events.json bot-repo/events.json
40+
41+
- name: Validate environment variables
42+
env:
43+
MASTODON_API_BASE_URL: ${{ vars.MASTODON_API_BASE_URL }}
44+
run: |
45+
if [ -z "$MASTODON_API_BASE_URL" ]; then
46+
echo "Error: MASTODON_API_BASE_URL is not set"
47+
exit 1
48+
fi
49+
# Check if URL looks valid (should start with http:// or https://)
50+
if [[ ! "$MASTODON_API_BASE_URL" =~ ^https?:// ]]; then
51+
echo "Error: MASTODON_API_BASE_URL should start with http:// or https://"
52+
echo "Current value starts with: ${MASTODON_API_BASE_URL:0:10}"
53+
exit 1
54+
fi
55+
# Check if URL is not just "https://" or "http://"
56+
if [[ "$MASTODON_API_BASE_URL" =~ ^https?://$ ]] || [[ "$MASTODON_API_BASE_URL" == "https" ]] || [[ "$MASTODON_API_BASE_URL" == "http" ]]; then
57+
echo "Error: MASTODON_API_BASE_URL appears to be incomplete. It should be a full URL like https://mastodon.social"
58+
exit 1
59+
fi
60+
echo "MASTODON_API_BASE_URL validation passed"
61+
62+
- name: Run mastodon reminder bot
63+
working-directory: bot-repo
64+
env:
65+
MASTODON_API_BASE_URL: ${{ vars.MASTODON_API_BASE_URL }}
66+
MASTODON_CLIENT_ID: ${{ secrets.MASTODON_CLIENT_ID }}
67+
MASTODON_CLIENT_SECRET: ${{ secrets.MASTODON_CLIENT_SECRET }}
68+
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
69+
run: |
70+
python mastodon-reminder.py events.json

0 commit comments

Comments
 (0)