feat: Heroku Scheduler から GitHub Actions への定期タスク移行#1803
Merged
Conversation
- daily.yml に upcoming_events:aggregation タスクを追加(毎日 0:00 UTC / 9:00 JST) - weekly.yml を新規作成し statistics:aggregation タスクを追加(毎週月曜 1:00 AM UTC / 10:00 AM JST) - README.md を更新し、Heroku Scheduler から GitHub Actions への移行を反映
- レビュー時に実行内容が最初に見えるように run を先に配置 - -a オプションを --app に変更(より明示的) - 1行で収まるコマンドは行継続を削除
- saijo.doorkeeper.jp → coderdojo-saijo.doorkeeper.jp - 正しい URL に修正してイベント取得を可能にする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Heroku Scheduler から GitHub Actions への定期タスク移行を実施しました。
変更内容
追加
.github/workflows/daily.yml-upcoming_events:aggregationタスクを追加(毎日 0:00 UTC / 9:00 JST).github/workflows/weekly.yml-statistics:aggregationタスクを追加(毎週月曜 1:00 AM UTC / 10:00 AM JST)更新
README.md- Heroku Scheduler から GitHub Actions への移行を反映採用したアプローチ
✅ アプローチ A: Heroku CLI 経由で本番環境のタスクを実行
メリット
DATABASE_URLを GitHub Secrets に保存不要HEROKU_API_KEYとHEROKU_APP_NAMEを再利用run:をenv:より先に配置、--appオプション使用)検討したが今回は選択しなかったアプローチ
❌ アプローチ B: GitHub Actions 内で直接実行(完全移行)
多くの Rails OSS プロジェクトが採用しているパターン:
メリット
デメリット
DATABASE_URL(本番 DB 接続情報)を GitHub Secrets に保存必要将来的な完全移行の可能性
Heroku からの完全移行を検討する場合、以下のオプションがあります:
Render / Fly.io などへの移行
Sidekiq Cron / SolidQueue の採用
Docker 化
参考資料
テスト方法
ローカル環境でのテスト
テスト結果:
CoderDojo愛媛新居浜 #1(2026年4月5日)第2回 CoderDojo 西条 @広島大学(2026年3月28日)saijo.doorkeeper.jp→coderdojo-saijo.doorkeeper.jp)手動実行テスト
GitHub Actions の UI から手動実行可能:
Daily WorkflowまたはWeekly Workflowを選択Run workflowボタンをクリック期待される動作
daily.yml: 毎日 0:00 UTC(日本時間 9:00 AM)に自動実行weekly.yml: 毎週月曜 1:00 AM UTC(日本時間 10:00 AM)に自動実行チェックリスト
GitHub Secrets に
HEROKU_API_KEYが設定されている(既存)GitHub Secrets に
HEROKU_APP_NAMEが設定されている(既存)ローカル環境でタスク実行をテスト
PR マージ後、手動実行でテスト
# Actions タブから手動実行、または gh workflow run daily.yml gh workflow run weekly.yml1週間後、自動実行が正常に動作していることを確認→ エラーが出たら随時対応Heroku Scheduler の設定を削除 (復元用にメモ)
[ $(date +%u) = 1 ] && bundle exec rails statistics:aggregation(Every day at 1am UTC)bundle exec rails upcoming_events:aggregation(Every dat at 9pm UTC)