Skip to content

Mastodon Reminder Bot #8

Mastodon Reminder Bot

Mastodon Reminder Bot #8

name: Mastodon Reminder Bot
on:
schedule:
# Run daily at 9 AM UTC
- cron: '0 9 * * *'
workflow_dispatch: # Allow manual triggering
jobs:
run-bot:
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