Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Daily Workflow

on:
schedule:
# 毎朝 9:00 JST
- cron: '0 0 * * *'
# Allows you to run this workflow manually from the Actions tab
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
workflow_dispatch:

jobs:
daily:
runs-on: ubuntu-latest
outputs:
FOUND_NEWS: ${{ steps.check_news.outputs.FOUND_NEWS }}

steps:
- name: ☑️ Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: 💎 Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: 📰 Run news:fetch task
run: bin/rails news:fetch

- name: 🆙 Commit updated news.yml
id: check_news
run: |
git config user.name "Yohei Yasukawa"
git config user.email "[email protected]"
git checkout main
git add db/news.yml
if ! git diff --cached --quiet; then
git commit -m '🤖 Upsert db/news.yml'
git push origin main
echo "🆕 Found news in db/news.yml"
echo "FOUND_NEWS=true" >> $GITHUB_OUTPUT
else
echo "✅ No news in db/news.yml"
echo "FOUND_NEWS=false" >> $GITHUB_OUTPUT
fi

deploy:
needs: daily
if: ${{ needs.daily.outputs.FOUND_NEWS == 'true' }}
runs-on: ubuntu-latest

steps:
- name: ☑️ Checkout code
uses: actions/checkout@v4
with:
ref: main

- name: 🚀 Deploy to Heroku
uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
heroku_email: ${{ secrets.HEROKU_EMAIL }}
39 changes: 0 additions & 39 deletions .github/workflows/fetch_news.yml

This file was deleted.