Skip to content

Update Jokes

Update Jokes #10

Workflow file for this run

name: Update Jokes
on:
schedule:
- cron: "0 0 */2 * *" # Runs every day at midnight UTC
workflow_dispatch: # Allows manual trigger
jobs:
update-jokes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: true # Ensure we have credentials for pushing
- name: Ensure cowsay directory exists
run: mkdir -p cowsay # Ensure the directory exists
- name: Fetch new jokes
run: |
curl -s -H "Accept: application/json" "https://icanhazdadjoke.com/search?limit=100" | jq -r '.results[].joke' > cowsay/jokes.txt
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add cowsay/jokes.txt
git diff --staged --quiet || (git commit -m "Auto-update jokes.txt [$(date)]" && git push origin main)