Skip to content

Commit 9d8fe5c

Browse files
authored
Merge pull request #1748 from coderdojo-japan/fix-automate-updating-news
Fix: Failed to update news section automatically
2 parents 0d9d651 + e9f9223 commit 9d8fe5c

File tree

2 files changed

+64
-39
lines changed

2 files changed

+64
-39
lines changed

.github/workflows/daily.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Daily Workflow
2+
3+
on:
4+
schedule:
5+
# 毎朝 9:00 JST
6+
- cron: '0 0 * * *'
7+
# Allows you to run this workflow manually from the Actions tab
8+
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
9+
workflow_dispatch:
10+
11+
jobs:
12+
daily:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
FOUND_NEWS: ${{ steps.check_news.outputs.FOUND_NEWS }}
16+
17+
steps:
18+
- name: ☑️ Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 2
22+
23+
- name: 💎 Setup Ruby
24+
uses: ruby/setup-ruby@v1
25+
with:
26+
bundler-cache: true
27+
28+
- name: 📰 Run news:fetch task
29+
run: bin/rails news:fetch
30+
31+
- name: 🆙 Commit updated news.yml
32+
id: check_news
33+
run: |
34+
git config user.name "Yohei Yasukawa"
35+
git config user.email "[email protected]"
36+
git checkout main
37+
git add db/news.yml
38+
if ! git diff --cached --quiet; then
39+
git commit -m '🤖 Upsert db/news.yml'
40+
git push origin main
41+
echo "🆕 Found news in db/news.yml"
42+
echo "FOUND_NEWS=true" >> $GITHUB_OUTPUT
43+
else
44+
echo "✅ No news in db/news.yml"
45+
echo "FOUND_NEWS=false" >> $GITHUB_OUTPUT
46+
fi
47+
48+
deploy:
49+
needs: daily
50+
if: ${{ needs.daily.outputs.FOUND_NEWS == 'true' }}
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- name: ☑️ Checkout code
55+
uses: actions/checkout@v4
56+
with:
57+
ref: main
58+
59+
- name: 🚀 Deploy to Heroku
60+
uses: akhileshns/[email protected]
61+
with:
62+
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
63+
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
64+
heroku_email: ${{ secrets.HEROKU_EMAIL }}

.github/workflows/fetch_news.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)