An automated service that generates daily on-brand graphics for Apes On Keys by:
- Pulling product & grid images from Shopify and the a-ok.shop gallery API and summarising them with GPT-4o Vision
- Generating fresh graphics using OpenAI's DALL-E 3
- Storing the results in the local repo under
public/daily/ - Updating a manifest of generated images
- Triggering a Vercel deployment
-
Install dependencies:
npm install
-
Copy
.env.exampleto.envand fill in your credentials:cp .env.example .env
-
Required environment variables:
SHOPIFY_DOMAIN: Your Shopify store domainSHOPIFY_STOREFRONT_TOKEN: Shopify Storefront API tokenOPENAI_API_KEY: OpenAI API keyVERCEL_DEPLOY_HOOK_URL: Vercel deployment webhook URL
Run the generator locally:
npm startThe service runs automatically at 13:00 UTC daily via GitHub Actions. You can also trigger it manually from the Actions tab.
Generated images are stored in the repo under public/daily/ with filenames in the format YYYY-MM-DD.png. The manifest.json file keeps track of all generated images with their prompts and URLs.
GitHub Actions (cron)
└─▶ Node script (src/index.ts)
├─ fetchShopifyMedia.ts ← Storefront GraphQL API
├─ listGridImages.ts ← a-ok.shop gallery API
├─ describeImage.ts ← GPT-4o Vision summaries
├─ craftPrompt.ts ← brand rules + descriptors
├─ generateImage.ts ← OpenAI imagegen 1×1024 PNG
└─ manifest.json update + Vercel Deploy Hook
| Item | Purpose |
|---|---|
| Node ≥ 20 | Runtime for the agent scripts |
| GitHub repo | Hosts code & scheduled workflow |
| Shopify Storefront API token | Read-only access to product media |
| OpenAI API key | GPT-4o Vision + Image Generation |
| Vercel Deploy Hook URL | Triggers storefront rebuild after each image |
Add these as GitHub Secrets (repo → Settings → Secrets → Actions):
OPENAI_API_KEY = x-sk-...
SHOPIFY_DOMAIN = a-ok.myshopify.com
SHOPIFY_STOREFRONT_TOKEN = shpat_...
VERCEL_DEPLOY_HOOK_URL = https://api.vercel.com/...- Brand rules are a single string in
src/craftPrompt.ts. Tweak typography, palette, or vibe there. - Image size (
generateImage.ts) defaults to 1024×1024; change to 1792×1024 if you want a banner.
- Script aborts if OpenAI spend today ≥ $0.20 (see
checkUsage()helper). - If Shopify or the gallery API fails → the GitHub job exits without touching manifest or triggering deploy.
- Previous day's art remains live—storefront never breaks.