Daily Word #56
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 Word | |
| on: | |
| schedule: | |
| - cron: '0 5 * * *' # 6 AM CET (UTC+1); 7 AM CEST (UTC+2) in summer | |
| workflow_dispatch: # allow manual trigger from GitHub Actions UI | |
| jobs: | |
| update-word: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Pick random unused word, write JSON, and commit | |
| run: | | |
| DATE=$(TZ="Europe/Budapest" date +%Y-%m-%d) | |
| # Extract already-used words: only those with non-empty reflections | |
| USED_WORDS=$(jq -r '.[] | select(.text != "") | .word' data/reflections.json) | |
| # Pick a random word not in the history; fall back to fully random if exhausted | |
| WORD=$(grep -vxFf <(echo "$USED_WORDS") data/words.txt | shuf -n 1) | |
| if [ -z "$WORD" ]; then | |
| WORD=$(shuf -n 1 data/words.txt) | |
| fi | |
| # Update word-of-day.json | |
| echo "{\"word\": \"$WORD\", \"date\": \"$DATE\"}" > data/word-of-day.json | |
| # Prepend to words-history.json | |
| jq --arg word "$WORD" --arg date "$DATE" \ | |
| '[{"word": $word, "date": $date}] + .' \ | |
| data/words-history.json > tmp.json && mv tmp.json data/words-history.json | |
| # Append new entry to reflections.json | |
| jq --indent 4 --arg date "$DATE" --arg word "$WORD" \ | |
| '. + [{"date": $date, "word": $word, "text": ""}]' \ | |
| data/reflections.json > tmp.json && mv tmp.json data/reflections.json | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add data/word-of-day.json data/words-history.json data/reflections.json | |
| git commit -m "Daily word: $WORD" | |
| git push |