Daily AI Update (Theme & Timeline) #82
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 AI Update (Theme & Timeline) | |
| on: | |
| # Run every day at 08:00 UTC | |
| schedule: | |
| - cron: '0 8 * * *' | |
| # Allow manual trigger from GitHub Actions UI | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| models: read | |
| jobs: | |
| update-theme: | |
| name: Generate new theme with GitHub Models | |
| runs-on: ubuntu-latest | |
| steps: | |
| # ── Checkout ──────────────────────────────────────────────────────────── | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # Use a PAT if you want the push to trigger downstream workflows (e.g. Cloudflare Pages) | |
| # Otherwise GITHUB_TOKEN is sufficient for the commit itself. | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| # ── Node.js ───────────────────────────────────────────────────────────── | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| # ── Install deps ───────────────────────────────────────────────────────── | |
| - name: Install dependencies | |
| run: npm ci | |
| # ── Run AI theme update ────────────────────────────────────────────────── | |
| - name: Update theme.json via GitHub Models API | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: node scripts/update-theme.js | |
| # ── Run AI timeline update ──────────────────────────────────────────────── | |
| - name: Update timeline.json via GitHub Models API | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: node scripts/update-timeline.js | |
| # ── Check for changes ──────────────────────────────────────────────────── | |
| - name: Check what changed | |
| id: changes | |
| run: | | |
| THEME_CHANGED=false | |
| TIMELINE_CHANGED=false | |
| git diff --quiet src/theme.json || THEME_CHANGED=true | |
| git diff --quiet src/data/timeline.json || TIMELINE_CHANGED=true | |
| echo "theme=${THEME_CHANGED}" >> "$GITHUB_OUTPUT" | |
| echo "timeline=${TIMELINE_CHANGED}" >> "$GITHUB_OUTPUT" | |
| if $THEME_CHANGED || $TIMELINE_CHANGED; then | |
| echo "any=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "any=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| # ── Commit & push ──────────────────────────────────────────────────────── | |
| - name: Commit AI updates | |
| if: steps.changes.outputs.any == 'true' | |
| run: | | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| DATE=$(date -u '+%Y-%m-%d') | |
| # Stage only the files that actually changed | |
| git diff --quiet src/theme.json || git add src/theme.json | |
| git diff --quiet src/data/timeline.json || git add src/data/timeline.json | |
| # Build a descriptive commit message | |
| PARTS=() | |
| ${{ steps.changes.outputs.theme == 'true' && 'true' || 'false' }} && PARTS+=("theme") | |
| ${{ steps.changes.outputs.timeline == 'true' && 'true' || 'false' }} && PARTS+=("timeline") | |
| CHANGED=$(IFS=', '; echo "${PARTS[*]}") | |
| git commit -m "chore(ai): daily update — ${CHANGED} (${DATE}) | |
| Automated daily refresh by GitHub Copilot (GitHub Models API). | |
| - theme: aesthetic & color palette updated based on current design trends | |
| - timeline: new AI milestones appended if any significant events detected" | |
| git push | |
| # ── No-op log ──────────────────────────────────────────────────────────── | |
| - name: Log if no changes | |
| if: steps.changes.outputs.any == 'false' | |
| run: echo "No files changed by either AI script. Nothing to commit." |