Skip to content

Daily Bot — Auto-post to Lemmy / Mastodon / Dev.to + IndexNow #79

Daily Bot — Auto-post to Lemmy / Mastodon / Dev.to + IndexNow

Daily Bot — Auto-post to Lemmy / Mastodon / Dev.to + IndexNow #79

Workflow file for this run

name: Daily Bot — Auto-post to Lemmy / Mastodon / Dev.to + IndexNow
on:
# 매일 UTC 16:00 = 한국시간(KST) 새벽 1:00에 자동 실행
schedule:
- cron: '0 16 * * *'
# 수동 트리거도 가능 (Actions 탭에서 "Run workflow" 버튼)
workflow_dispatch:
permissions:
contents: write # state 파일 커밋용
jobs:
post:
runs-on: ubuntu-latest
# 랜덤 지연(최대 45분) + 봇 실행 시간을 모두 수용해야 함.
# 이전: timeout 10분 < 지연 최대 120분 → 매일 sleep 중 타임아웃되어 "Run all bots"가 SKIP됨(미게시).
timeout-minutes: 60
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Random delay (anti-bot pattern)
# 봇 의심 회피: 매일 정확히 같은 시각 게시 X
# 0~7200초(0~2시간) 랜덤 지연 → 게시 시각 분산
# 수동 실행(workflow_dispatch)에서는 지연 없음
if: github.event_name == 'schedule'
run: |
# 0~2700초(0~45분) 랜덤 지연 → 게시 시각 분산 (timeout 60분 이내)
DELAY=$((RANDOM % 2700))
echo "Random delay: ${DELAY} seconds (≈ $((DELAY / 60)) min)"
sleep ${DELAY}
- name: Run all bots
env:
# ─── Lemmy ───
LEMMY_INSTANCE: lemmy.world
LEMMY_USERNAME: ${{ secrets.LEMMY_USERNAME }}
LEMMY_PASSWORD: ${{ secrets.LEMMY_PASSWORD }}
# ─── Mastodon ───
MASTODON_INSTANCE: mastodon.social
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
# ─── Dev.to ───
DEVTO_API_KEY: ${{ secrets.DEVTO_API_KEY }}
# ─── Bluesky (AT Protocol, 봇 공식 허용) ───
BLUESKY_HANDLE: ${{ secrets.BLUESKY_HANDLE }}
BLUESKY_APP_PASSWORD: ${{ secrets.BLUESKY_APP_PASSWORD }}
# ─── 텔레그램 채널 ───
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHANNEL: ${{ secrets.TELEGRAM_CHANNEL }}
# ─── Pinterest ───
PINTEREST_ACCESS_TOKEN: ${{ secrets.PINTEREST_ACCESS_TOKEN }}
PINTEREST_BOARD_ID: ${{ secrets.PINTEREST_BOARD_ID }}
# ─── Reddit (계정 숙성 후) ───
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }}
REDDIT_USERNAME: ${{ secrets.REDDIT_USERNAME }}
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}
# ─── 공통 ───
SITE_URL: https://tarofortune.pythonanywhere.com
SITE_HOST: tarofortune.pythonanywhere.com
# Lemmy/Mastodon/Dev.to는 multi-site-bot.yml(3사이트 회전)이 담당 → 중복 게시 방지.
# 이 워크플로우는 Bluesky/Telegram/Pinterest/Reddit(+IndexNow)만 담당.
SKIP_CHANNELS: lemmy,mastodon,devto
run: |
python -X utf8 run_all_bots.py
- name: Commit state files (중복 방지 상태 영구 저장)
run: |
git config user.name "tarofortune-bot"
git config user.email "bot@tarofortune.pythonanywhere.com"
git add .lemmy_state.json .mastodon_state.json .devto_state.json .bluesky_state.json .telegram_state.json .pinterest_state.json 2>/dev/null || true
if ! git diff --cached --quiet; then
git commit -m "chore: bot state $(date -u +%Y-%m-%dT%H:%M:%SZ)"
git push
else
echo "No state changes to commit."
fi