Daily Story Fetch #208
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Daily Story Fetch | |
| on: | |
| schedule: | |
| - cron: "0 19 * * *" # Run every day at 19:00 UTC | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: 3.3 | |
| - name: Install Ruby dependencies | |
| run: gem install nokogiri pry --no-document | |
| - name: Run fetch script if stories.json is missing or outdated | |
| run: | | |
| if [ ! -f stories.json ]; then | |
| echo "stories.json not found. Running Ruby script..." | |
| ruby fetch.rb | |
| else | |
| echo "stories.json already exists. Proceeding to refresh..." | |
| ruby fetch.rb | |
| fi | |
| - name: Commit and push changes (if any) | |
| run: | | |
| git config --global user.name 'github-actions' | |
| git config --global user.email 'actions@github.com' | |
| git add stories.json | |
| git commit -m "Auto-update stories.json [CI]" || echo "No changes" | |
| git push |