Skip to content

Scheduler (Every 30 minutes) #59714

Scheduler (Every 30 minutes)

Scheduler (Every 30 minutes) #59714

Workflow file for this run

name: Scheduler (Every 30 minutes)
# Spec: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule
# For debug: https://crontab.guru/
on:
schedule:
- cron: '*/30 * * * *'
# 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:
build:
runs-on: ubuntu-latest
steps:
- name: ☑️ Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: 💎 Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
#ruby-version: 2.7 # Not necessary if .ruby-version is given
- name: 🧪 Install Ruby gems with 'actions' group
run: |
bundle config set with 'actions'
bundle config set path 'vendor/bundle'
bundle install --jobs 4 --retry 3
- name: 🔔 Notify fetched articles from RSS
run: bundle exec rake share_rss_articles
env:
SLACK_SHARE: ${{ secrets.SLACK_SHARE }}
- name: 📜 Upsert recent articles from note.com
run: |
bundle exec rake upsert_recent_notes
echo "NEW_NOTE=false" >> $GITHUB_ENV
if [ -n "$(git status --porcelain)" ]; then
if ( ruby -ryaml -e "p YAML.unsafe_load(STDIN.read)" < _data/news.yml > /dev/null ); then
git config --global user.name "Yohei Yasukawa"
git config --global user.email "yohei@yasslab.jp"
git checkout main
git add _data/news.yml
git commit -m '🤖 Upsert note article(s) by GitHub Actions'
git push origin main
echo "NEW_NOTE=true" >> $GITHUB_ENV
echo "Found new article(s) in note."
else
echo "Detected YAML syntax error in '_data/news.yml' so not going to deploy."
fi
fi
env:
GITHUB_TOKEN:
- name: ✅ No recent articles found
if: ${{ env.NEW_NOTE == 'false' }}
run: |
echo "No recent articles found in note."
- name: 🚀 Deploy to Heroku if recent article(s) found
if: ${{ env.NEW_NOTE == 'true' }}
uses: akhileshns/heroku-deploy@v3.12.13
with:
branch: 'main'
usedocker: false
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: 'yasslab-jp'
heroku_email: 'yohei@yasslab.jp'
healthcheck: 'https://yasslab.jp/health'