Skip to content

Run deploy job when daily task(s) finished and found news in Actions #1

Run deploy job when daily task(s) finished and found news in Actions

Run deploy job when daily task(s) finished and found news in Actions #1

Workflow file for this run

name: Daily Workflow

Check failure on line 1 in .github/workflows/daily.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/daily.yml

Invalid workflow file

(Line: 57, Col: 7): Unexpected value 'runs-on', (Line: 58, Col: 7): Unexpected value 'steps', (Line: 53, Col: 7): There's not enough info to determine what you meant. Add one of these properties: run, shell, uses, with, working-directory
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
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: 🧪 Install dependencies
run: bundle install
- name: 📰 Run news:fetch task
run: bin/rails news:fetch
- name: 🆙 Commit updated news.yml
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_ENV
else
echo "✅ No news in db/news.yml"
echo "FOUND_NEWS=false" >> $GITHUB_ENV
fi
- name: ✅ Do nothing if no news found
if: ${{ env.FOUND_NEWS == 'false' }}
run: |
echo "No news found."
- name: 🚀 Deploy to Heroku if news found
if: ${{ env.FOUND_NEWS == 'true' }}
# TODO: This workflows depend on Ubuntu version.
# https://github.com/AkhileshNS/heroku-deploy/issues/186
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
heroku_email: ${{ secrets.HEROKU_EMAIL }}