Skip to content

Commit 2a9c1f2

Browse files
committed
ci: news:fetchタスクを毎朝9:00 JSTに実行するワークフローを追加
- .github/workflows/fetch_news.yml を作成 - cron('0 0 * * *') で毎朝 9:00 JST に自動実行を設定 - workflow_dispatch による手動トリガーを有効化 - ruby/setup-ruby で から Ruby をセットアップ+bundler-cache を有効化 - news:fetch タスク実行後に db/news.yml の差分をコミット&プッシュする処理を追加
1 parent 92dd480 commit 2a9c1f2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/fetch_news.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Fetch News
2+
3+
on:
4+
schedule:
5+
# 毎朝 9:00 JST
6+
- cron: '0 0 * * *'
7+
workflow_dispatch:
8+
9+
jobs:
10+
fetch:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Ruby
18+
uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version-file: .ruby-version
21+
bundler-cache: true
22+
23+
- name: Install dependencies
24+
run: bundle install --jobs 4 --retry 3
25+
26+
- name: Run news:fetch task
27+
run: bin/rails news:fetch
28+
29+
- name: Commit updated news.yml
30+
run: |
31+
git config user.name "github-actions[bot]"
32+
git config user.email "github-actions[bot]@users.noreply.github.com"
33+
git add db/news.yml
34+
if ! git diff --cached --quiet; then
35+
git commit -m "chore: update news.yml via GitHub Actions"
36+
git push
37+
else
38+
echo "No changes in db/news.yml"
39+
fi

0 commit comments

Comments
 (0)