-
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (80 loc) · 4.53 KB
/
Copy pathdaily-theme-update.yml
File metadata and controls
95 lines (80 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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."